Windows commandPrompt shell: nested quotes in cmd.exe /c command are not preserved
What version of Codex is running?
codex-cli 0.142.3
Codex app/session context also included BROWSER_USE_CODEX_APP_VERSION=26.623.42026. I did not independently check the About Codex dialog.
What platform is your computer?
Microsoft Windows [Version 10.0.26200.8737] x64
Shell/config context:
- Native Windows Codex session
sandbox_mode = "workspace-write"[windows] sandbox = "elevated"- Desktop setting
integratedTerminalShell = "commandPrompt" - The tool call selected
shell="cmd" - Node:
v26.3.0, resolved asC:\Program Files\nodejs\node.exe
What issue are you seeing?
A Codex shell/tool command using the Windows cmd shell failed because nested double quotes were not preserved through the cmd.exe /c wrapper.
The command I asked the tool layer to run was:
.\.venv\Scripts\activate.bat && node -e "console.log('node ok')"
The visible command shape in the session/log was effectively:
C:\WINDOWS\system32\cmd.exe" /c ".\.venv\Scripts\activate.bat && node -e "console.log('node ok')
The inner quote before console.log(...) appears to terminate or corrupt the /c command string instead of being passed as part of the node -e argument. Node then received a malformed script and failed with:
[eval]:1
"console.log('node
^^^^^^^^^^^^^^^^^^
Unterminated string constant
SyntaxError: Invalid or unexpected token
at makeContextifyScript (node:internal/vm:194:14)
at compileScript (node:internal/process/execution:420:10)
at evalTypeScript (node:internal/process/execution:292:22)
at node:internal/main/eval_string:71:3
Node.js v26.3.0
This is separate from a local Python virtual-environment access problem that was being investigated in the same session. Simple commands without nested quoting, such as node --version, where node, and ver, worked.
What steps can reproduce the bug?
- Start a native Windows Codex session using the commandPrompt/cmd shell path.
- Run a command through the Codex shell/tool layer with
shell="cmd"that contains an inner double-quoted argument, for example:
node -e "console.log('node ok')"
or, in a Python project that activates a venv first:
.\.venv\Scripts\activate.bat && node -e "console.log('node ok')"
- Observe that the inner quotes are not preserved through the
cmd.exe /c "..."layer and Node receives a malformed eval string.
What is the expected behavior?
Either:
- Codex should transport/escape the command string so a common command like
node -e "console.log('node ok')"reachescmd.exe/Node correctly, or - Codex should reject or clearly diagnose command strings that contain unsupported nested quoting for the selected Windows shell.
The expected Node behavior is simply:
node ok
Related issues checked
I searched existing issues before filing this. These are related but not exact matches:
- #9581: closed as model behavior; covers fragile Windows
cmd.exe /cquoting and inline interpreter failures, but it was closed and predates this0.142.3repro. - #21667: open, but about unquoted PowerShell path metacharacters.
- #23484: open, but about approval-rule parsing for bare comma
gh --jsonargs. - #17451: open, but about Node script execution crashing with
ncrypto::CSPRNG(nullptr, 0), whereas this repro is a NodeSyntaxErrorcaused by malformed quoting.
Additional information
This may still be partly agent-command-generation behavior: an agent chose a nested-quote one-liner. The reason I am filing this separately is that quoted arguments are common on Windows (node -e, python -c, gh --json "...", search strings, etc.), and the tool layer either needs to preserve them safely for the selected shell or surface a deterministic diagnostic so agents can choose a safer transport before executing.