Skip to content

shell: quoted backticks rejected as command-substitution while $() passes #64066

Closed

Description

@senseikatana

Summary

The portable shell scanner hard-rejects any command containing backticks, even literal ones inside quoted strings, with Portable shell scanner cannot analyze command: command-substitution. Equivalent real $(...) command substitution executes fine. There is no override or escape hatch.

Environment

  • opencode version: v2.3.0
  • OS: Linux 7.2.9-1-MANJARO x86_64 GNU/Linux
  • Terminal: WaveTerm (TERM=xterm-256color, COLORTERM=truecolor, TERM_PROGRAM=waveterm)
  • Shell: /bin/zsh
  • Install/channel: latest
  • Active plugins: none found in config

Reproduction

  1. Send a shell command containing a literal backtick inside a double-quoted string, e.g. echoing a markdown code-fence sample: echo "fences look like ```ts ... ```".
  2. The tool refuses with: Portable shell scanner cannot analyze command: command-substitution.
  3. For contrast, send a real command substitution: x=$(echo hi); echo "$x" — this executes normally.

Expected Behavior

Either execute the command in the real shell (it is valid shell syntax), or return an actionable error such as "backticks inside double quotes execute as command substitution — escape them", ideally with an escape/opt-out.

Actual Behavior

Hard reject with an internal-sounding message and no workaround; small rewordings hit the same wall. The command cannot be run at all.

Additional Context

POSIX-sh does treat quoted backticks as substitution, so the detection itself is not wrong — but the treatment is inconsistent with $(...) being allowed through, and the message gives the user no path forward. Workaround used: rewrite the command to avoid backticks entirely.

Activity

  1. opencodejr commented on Nov 15, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report.

    As I understand it, you'd like the shell tool to give a useful error, and ideally a way around it, when it refuses a command because of backticks. Today you only get Portable shell scanner cannot analyze command: command-substitution.

    Refusing is intended. The permissions docs say that a command the scanner can't safely analyze "returns a scanner error rather than executing unverified subcommands". The scanner reads the text between backticks the same way it reads $(...). In the code I read, it only refuses when that inner text can't be analyzed or a backtick is never closed.

    When I ran the scanner from the source on your example, echo "fences look like ```ts ... ```", it was accepted. Single-quoted backticks were accepted too. An unclosed backtick inside double quotes was refused. So the command that was actually refused probably differed from the example. If you still have it, please post the exact command.

    What's left is the request for a clearer message and possibly an opt-out, and maintainers will consider it. Related:

    Until then, the workarounds are single quotes, escaping each backtick as \``, or writing the text to a file and passing "$(cat file)"`.

  2. added
    area/core
    type/feature
    version/v2
    on Nov 15, 2026
  3. neriousy commented on Nov 23, 2026

    @neriousy
    Member

    This was fixed in #65269, which makes commands the shell scanner can't analyze ask for permission instead of failing, so quoted backticks can run after approval. If you still see this on the latest version, comment here and we'll reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreplatform/linuxtype/featureversion/v2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions