Repository navigation
fix(scripts): double backslashes before a quote in win-shell-args - #5143
Conversation
An argument ending in a backslash was quoted as "...\\", which the CRT parser reads as an escaped quote, swallowing the rest of the command line. Backslash runs before an embedded quote or the closing quote are now doubled, with tests including a round trip through a reference CRT parser. Closes #5111 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
|
|
| Tools | Prompts | Resources | Resource templates | |
|---|---|---|---|---|
| Base | 22 | 4 | 7 | 3 |
| Head | 22 | 4 | 7 | 3 |
Updated by this run for fd55745f663d25622ed1478ae199f8e145bc15d1.
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix satisfies #5111 and is supported by comprehensive regression tests.
0 open findings
What changed in this PR
Fixes Windows shell argument quoting so backslashes preceding quotes survive CRT parsing correctly.
Changes:
- Doubles backslash runs before embedded and closing quotes.
- Adds targeted expectations and CRT round-trip regression tests.
| File | Description |
|---|---|
scripts/lib/win-shell-args.mjs |
Corrects Windows argument escaping. |
scripts/lib/win-shell-args.test.mjs |
Covers trailing backslashes, embedded quotes, and round trips. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
Copilot round 1: clean (0 findings, approval recommended). Loop stopped on the first clean round; nothing pushed after the review. |
Closes #5111
Description
quoteWinArg(scripts/lib/win-shell-args.mjs) wrapped an argument in"…"and doubled inner quotes, but left backslashes alone. Under the Windows CRT argument rules, backslashes are literal except before a", where 2n backslashes yield n and leave the quote special. SoC:\a b\was quoted as"C:\a b\", whose final\"reads as an escaped quote rather than the closing one, and the child received a different argument with the rest of the command line swallowed into it. Backslashes before an embedded quote had the same problem.Now any run of backslashes that ends up in front of a quote is doubled: one before an embedded
", and a trailing run, which the closing quote follows. The embedded"itself stays doubled as""rather than written\", because""keepscmd.exe's own quote tracking in step, while\"would flip it and expose any metacharacter after it.Server Details
None (repository-wide): dev tooling only. The callers are
verify-skills-cli.mjs,claude-cli.mjs,gate-lease.mjsandinterface-diff.mjs, and only on Windows. Nothing published uses it.Motivation and Context
Found by Copilot on the v1.0.0 merge PR #5090; tracked in #5111.
How Has This Been Tested?
No client-observable surface, so this carries a targeted probe instead of client evidence:
scripts/lib/win-shell-args.test.mjs: a trailing backslash (single and double), backslashes before an embedded quote, backslashes not followed by a quote left alone, and a round trip of every case through a reference MSVCRT (2008+) parser, so the expectations are checked against what the child actually receives rather than against a hand-written string.v2/main'swin-shell-args.mjsfails 3 of 11 (the trailing-backslash, embedded-quote and round-trip tests); against this branch, all 11 pass.npm run local:gate: exit 0.Breaking Changes
None.
Types of changes
Checklist
npm run changeset) if this changes what a TypeScript server publishes (not applicable: nothing published changes)%refusal is unchanged)🤖 Generated with Claude Code