Repository navigation
Fix: Windows quoting follows the C runtime backslash rules, shared quote vectors (F10) - #44
Merged
Merged
Conversation
…ectors (F10) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y2SN8SuEakTdiWy3F2WUqN
…e lifecycle findings remain)
Contributor
Author
|
Closed: included in #47 (merged with a merge commit, so these commits are in Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
command.quote(windows=True)broke texts with backslashes before a quote:C:\My Data\came out as"C:\My Data\", whose closing quote is swallowed.Now (
_quote_windows, CommandLineToArgvW/MSVCRT rules): backslashes are literal; a run of backslashes before a"is doubled and the quote escaped; a trailing run is doubled before the closing quote. Text made only of letters, digits and-_.:/\=+,stays bare; everything else, including empty text, is double-quoted. Examples:C:\My Data\->"C:\My Data\\",x y\"z->"x y\\\"z". The POSIX path (shlex.quote) and the signature are unchanged; output for texts without a backslash before a quote is unchanged, andtest_shell_quotingandtest_commandpass unmodified.Shared vectors for every host:
tests/quote_vectors.json(31{label, text, posix, windows}vectors: backslash, quote, space, unicode, percent, caret, ampersand, pipe/redirect, UNC, emoji, CJK, tab,!) andtests/test_quote_vectors.py(the function must equal every vector for both shells; everyposixvalue mustshlex.splitback to the text; everywindowsvalue must be one argument for the existing parser oracle). F10 and itswinquote:*,winproc:*and property entries are removed from the known failures, so those tests run normally.Decision recorded (cmd.exe): the Windows terminal line targets cmd.exe, not PowerShell (use the Python snippet in PowerShell). Inside the quotes
^ & | < >are literal and need nothing;%NAME%is still expanded by cmd.exe when NAME is defined, an odd number of"upsets cmd.exe's quote tracking for later operators, and a line break cannot be pasted into cmd.exe. These limits are documented indocs/HOST_FEATURES.md, not escaped: a caret-based escape cannot be unit-tested without cmd.exe, and it would break the tests that parsequoteoutput through the C-runtime oracle. If cmd-hardened output is wanted, those tests need a cmd stage and a Windows CI run.tests/test_sabotage.py: the POSIX break patch moved with the line; the old Windows break is replaced by two (no escape of", no doubling of trailing backslashes, guarded by the vectors test); the sabotage copy also copies the vectors file. Docs: ledger row,HOST_FEATURES.md.Host follow-ups (Fiji and QuPath Groovy
shellQuote, same change in both): the Windows branch returns the text unchanged if non-empty and every character is a letter, digit or one of-_.:/\=+,; otherwise"+ body +"where a backslash is emitted as-is unless it is followed by"or ends the text (a run before a quote is doubled, plus one extra backslash before the quote; a trailing run is doubled); keep the POSIX branch equal toshlex.quote; copyquote_vectors.jsoninto each repo's tests and add one test that loads it as UTF-8 and compares both shells. Vectors that fail on the current Groovy copies if they only escape":spaced-trailing-backslash,spaced-two-trailing-backslashes,quote-after-backslash,quote-after-two-backslashes,quote-after-three-backslashes,unc. Napari uses Tools'command_line: no change.Verified by the author on Linux, Python 3.11: black, ruff, mypy; the full suite (402 tests) has the two environmental failures plus one test (
test_generic_integration.test_7_cooperative_cancel_no_leaks) that compares the global/tmp/lcjob_*folders while other agents ran in parallel (passes alone). I re-ran lint and the quoting, command, round-trip command and known-failure suites (34 tests OK). Not verified: anything on real Windows. The evidence is the parser oracle and the vectors; the real-process-start Windows tests run in this PR's CI.🤖 Generated with Claude Code
https://claude.ai/code/session_01Y2SN8SuEakTdiWy3F2WUqN
Generated by Claude Code