Skip to content

fix(doctor): the shell check walked past the shim and told Windows to switch it off - #98

Open
xizhuomengcontin wants to merge 1 commit into
mainfrom
fix/doctor-shell-shim-windows
Open

xizhuomengcontin wants to merge 1 commit into
mainfrom
fix/doctor-shell-shim-windows

Conversation

@xizhuomengcontin

@xizhuomengcontin xizhuomengcontin commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Orca-Code-Review — push 1

Severity Count
P0 0
P1 0
P2 0
P3 0

✅ no blocking findings

shell shim  warn  commands pass through but nothing is captured
  fix: record with --no-shell rather than trusting a layer that records nothing

That is what orca doctor said on every Windows machine — advising the user to turn off a
capture layer that works fine.

Why

On Windows the shim is sh.cmd, because PATH cannot execute an extensionless script there.
installShellShim knows this and says so in its own doc comment. The check did not:

await execFileAsync('sh', ['-c', 'printf ok'], { env: { PATH: `${shim.dir}${delimiter}…` } });

execFile without a shell goes to CreateProcess, which looks for sh and sh.exe and never
sh.cmd. So the probe walked straight past the shim directory it had just prepended, found
whichever sh.exe was further down PATH — Git for Windows', here — ran the command through that,
and correctly observed that no frames had been written.

Measured, with the shim directory on PATH:

how sh -c "printf ok" was invoked stdout frames
execFile('sh', …) — what the check did "ok" 0
execFile('sh.cmd', …) spawn EINVAL
cmd.exe /d /s /c sh -c "printf ok" "ok" 1

The middle row is why naming the .cmd directly is not the fix: node has refused to spawn a
.cmd or .bat without a shell since CVE-2024-27980. The command processor is what resolves
PATHEXT, so it is what has to do the resolving.

The layer was never broken

A real orca record on Windows, with an agent that invokes a shell the way a Windows caller does:

{"type":"shell.exec","attrs":{"argv":["sh","-c","echo hello from the shell; exit 3"],"cwd":""}}
{"type":"shell.result","causes":[5],"attrs":{"exit_code":3,"signal":null,"duration_ms":27,}}

argv with its quoting intact, and exit_code: 3 — the exit code the failing test's own name says
a broken shim "loses silently". It was being recorded the whole time.

And now:

shell shim  ok  sh, bash, zsh — captured a test command

Scope

One branch in one check. POSIX takes the identical path it took before. The shim, the runner and
the frame format are untouched — the only thing that was wrong was how the check reached them.

Worth stating plainly, since it bounds the claim: a caller that bypasses PATHEXT — node's own
execFile without shell, as this check did — will not hit the shim on Windows. That is inherent
to a .cmd shim and not something this PR changes. What it changes is that doctor no longer
reports its own choice of spawn API as a failure of the thing it was measuring.

Windows: 10 failures before, 9 after. prettier --check, tsc --build --force,
scripts/conformance.mjs (63 events, 0 failures) and scripts/fidelity.mjs --check
(0 regressions) are clean.

🤖 Generated with Claude Code

… switch it off

On Windows the shim is `sh.cmd`, because PATH cannot execute an extensionless
script there. The check ran `execFile('sh', …)`, which goes to CreateProcess,
which looks for `sh` and `sh.exe` and never `sh.cmd`. So it resolved to
whichever `sh.exe` was further down PATH, ran the probe command through *that*,
found no frames and reported:

    shell shim  warn  commands pass through but nothing is captured
      fix: record with --no-shell rather than trusting a layer that records nothing

Every Windows user, every time — advising them to turn off a layer that works.
`orca doctor` exists to move a quiet failure forward in time; this was a loud
one it invented.

Naming `sh.cmd` directly is not the fix: node has refused to spawn a `.cmd`
without a shell since CVE-2024-27980 (`spawn EINVAL`). The command processor is
what resolves PATHEXT, so it is what has to do the resolving.

The layer itself was never broken. Through `cmd.exe`, a real `orca record` on
Windows captures argv with its quoting intact and the exit code the test's own
name says a broken shim loses:

    {"type":"shell.exec","attrs":{"argv":["sh","-c","echo hello from the shell; exit 3"],…}}
    {"type":"shell.result","causes":[5],"attrs":{"exit_code":3,"duration_ms":27,…}}

And `orca doctor` now says so:

    shell shim  ok  sh, bash, zsh — captured a test command

Windows: 10 failures before, 9 after. POSIX is untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@orcacode-review orcacode-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐳 OrcaCode Review

No findings — nothing to flag in this PR. Great work!

OrcaCode Review — Route Smarter. Ship Safer. Spend Less.
Engine-reported: 519 calls · 52.4M tokens · 99% cached

❤️ Share · Install OrcaCode Review

Free on GitHub — the review runs on your own OrcaRouter key. If it helped, a shout-out goes a long way.

Share: X · Reddit · LinkedIn
Follow: X · Discord · LinkedIn · OrcaRouter

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant