Repository navigation
Description
Summary
The shell tool's command scanner rejects a valid command containing an ANSI-C quoted string with a non-standard escape ($'\033\[?1049'), reporting Portable shell scanner cannot analyze command: unterminated-quote. The command never runs. Bash itself accepts it and preserves the backslash, and the same script runs fine when invoked as bash script.sh.
Environment
- opencode version: 2.2.7
- OS: Linux 7.3.4-1-cachyos (linux x64)
- Terminal: kitty, TERM=xterm-kitty, COLORTERM=truecolor
- Shell: fish (commands run by the shell tool)
- Install/channel: release binary
- Active plugins: local plugin, @dietrichgebert/ponytail
Reproduction
-
Run through the shell tool:
printf '%s' $'\033\[?1049' | od -c
-
The tool refuses to execute it and returns:
Portable shell scanner cannot analyze command: unterminated-quote
Expected Behavior
The command executes and prints:
0000000 033 \ [ ? 1 0 4 9
Bash treats \[ as an unrecognized escape and keeps the backslash, which is exactly what is needed to feed a literal [ to grep.
Actual Behavior
Nothing is executed; the tool returns an error before spawning the shell. Reproducible 100%.
Additional Context
Minimal failing token: $'\033\[?1049'.
Scanner accepts (so it is specifically the escape, not ANSI-C quoting itself):
$'\033]66;s='$'\033\\[?1049'(valid\\escape, then a plain[)- the same line inside a script, invoked as
bash script.sh
According to the minified bundle shipped in 2.2.7, the ANSI-C string parser accepts only \a \b \e \E \f \n \r \t \v \\ \' \" \?, \xNN, \uNNNN, \UNNNNNNNN and octal \NNN. Any other escape makes the parser return undefined, and the caller maps that to unterminated-quote. The message is misleading: the quote is terminated, the escape is simply unsupported.
Impact: valid shell commands are blocked, and the error text sends users looking for a quoting problem that does not exist. Workaround: double the backslash ($'\033\\[?1049') or wrap the snippet in a script file.
Activity
opencodejr commentedon Nov 16, 2026
Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the detailed report. I reproduced this on 2.2.7, using a simulated model to send the shell tool call. When the shell tool was given
printf '%s' $'\033\[?1049' | od -c, it refused it withPortable shell scanner cannot analyze command: unterminated-quoteand the command never ran. With the backslash doubled ($'\033\\[?1049'), it ran and printed0000000 033 \ [ ? 1 0 4 9, which is also what plainbashprints for the original command. It still happens on the latestdev(0796584).It matches what you found in the bundle: the scanner's
$'...'parser gives up on an escape it doesn't recognise, such as\[, and that is reported as an unterminated quote. Until it's fixed, doubling the backslash or putting the command in a script works. The recording and script below show both commands; the screenshot shows the end state.recording.mp4
Reproduction script (drive.ts)
Run it with opencode-drive:
opencode-drive run ./drive.ts. It drivesopencodefrom yourPATH; setOC_DEVto the path of an OpenCode checkout to run that from source instead.