Repository navigation
fix(windows): preserve backslashes before quotes in forced-quoted argv - #442
Merged
caomengxuan666 merged 2 commits intoOct 6, 2026
Conversation
Emit 2n + 1 backslashes before embedded double quotes so wildcard-protected arguments round-trip through the native child command-line parser. Keep ordinary and trailing backslash handling intact. Add a dependency-free native child argv regression and run it in Windows CI. The regression fails before the fix and passes afterward. All 624 library tests and the existing PowerShell argv contract pass; a freshly built Niubash also passes the reported Node inline-code assertion. GNU semantic reference: execute_cmd.c:5930 argument-vector construction, execute_cmd.c:6126 shell_execve(), execve call at line 6133. This is a Windows serialization correction, with no lexer/expansion or carrier changes. WSL GNU Bash 5.3 differential validation was unavailable (no installed distro). Refs unixwin/niubash#197
Member
|
Don't change ci.yml,Thanks! |
Restore .github/workflows/ci.yml to the PR base as requested by the maintainer. Keep the Windows argument serializer fix and native argv regression tests in src/executor/path.rs.
Author
|
@a-rookie-of-C-language Thanks for the review! I've withdrawn all changes to |
caomengxuan666
approved these changes
Oct 6, 2026
Member
|
@iwantobelieve Thanks for your contribution! |
This was referenced Oct 12, 2026
Closed
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.
Windows arguments containing
*,?, or[use forced quoting to prevent a child CRT from expanding literal wildcards. When such an argument also contains a backslash immediately before a double quote, the serializer preserves only the original backslashes plus one escape. This changes quoting state in the native child's command-line parser, corrupting or splitting the argument. A single-quotednode -eprogram with a JavaScript array literal reproduces the failure in Niubash 1.3.3.Emit
2n + 1backslashes before embedded quotes, preserve ordinary backslash runs, and keep doubling trailing runs. The wildcard/MSYS admission rules stay as they are. This corrects the Windows transport boundary shared by native and MSYS/Cygwin children.Closes unixwin/niubash#197.
Regression coverage
Add a native-child round-trip test using this crate's libtest executable as an argv observer, without Node, PowerShell, or a new dependency. It checks the reported JavaScript argument, all three wildcard triggers, zero through four backslashes before quotes, trailing runs, Unicode, and a final argument that catches quote-state leakage. The test failed against the old serializer and passes with this patch.
Validation
cargo fmt --checkandgit diff --checkpassed.cargo test --lib --locked: 624 passed, with the host'sWINUXSH_SHELL_PATH_STYLE/__RUBASH_PATH_STYLEunset in the test environment.rubash_to_powershell_preserves_native_argument_literalsCLI regression passed.cargo build --lockedsucceeded using this patched rubash checkout. Its freshly built executable ran the original complexnode -eassertion successfully on Windows 10 Pro 19045 / Node v24.19.0.Contract references
execute_cmd.c:5930materializes the argument vector andexecute_cmd.c:6126 shell_execve()passes it toexecveat line 6133. The Rust implementation preserves that literal argument contract through Windows command-line serialization; no GNU implementation code is copied.