Skip to content

Fish interpreter fails to execute code snippets with command substitution error: command substitutions not allowed in command position. Try var=(your-cmd) $var ... __cleanup() { #827

@suin

Description

@suin

Description

When specifying fish as the interpreter for a code snippet in Runme, the execution fails with a command substitution error. The same code snippet works correctly when using bash as the interpreter.

Environment

  • Runme version: 3.14.0
  • Fish version: 4.0.2
  • Bash version: 5.2.37

Steps to Reproduce

  1. Create a README.md file with a fish code block:

    ```fish {"interpreter":"fish","name":"fish-test"}
    echo "Hello, World!"
    ```
  2. Run the snippet using runme:

    runme run fish-test

Expected Behavior

The snippet should execute successfully and output:

Hello, World!

Actual Behavior

The execution fails with the following error:

/tmp/runme/.runme-script-01JYD6NM79ARD8D9CYNNX3T5JH.sh (line 2): command substitutions not allowed in command position. Try var=(your-cmd) $var ...
__cleanup() {
         ^^
warning: Error while reading file /tmp/runme/.runme-script-01JYD6NM79ARD8D9CYNNX3T5JH.sh
could not execute command: failed to run command "fish-test": exit code: 127

Additional Context

The same code snippet works correctly when using bash as the interpreter:

```bash {"interpreter":"bash","name":"bash-test"}
echo "Hello, World!"
```

Running runme run bash-test produces the expected output:

Hello, World!

Possible Cause

It appears that Runme might be generating a shell script with bash-specific syntax (such as the __cleanup() function definition) that is incompatible with fish shell's syntax. Fish has a different syntax for function definitions and doesn't support the same command substitution syntax as bash.

Suggested Solution

When using fish as an interpreter, Runme should either:

  1. Generate fish-compatible wrapper scripts, or
  2. Use a different approach that doesn't rely on bash-specific syntax in the wrapper script

Related Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions