fix: preserve Windows backslashes with --shell=none#884
Conversation
shell_words::split treats backslashes as escape characters, which breaks raw execution of Windows paths like Downloads\in.exe. Use a Windows-aware splitter that preserves backslashes when building std::process::Command. Fixes sharkdp#796 Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 71bc894682
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| '"' => { | ||
| in_double_quotes = !in_double_quotes; | ||
| current.push(ch); | ||
| } |
There was a problem hiding this comment.
Remove quote delimiters when splitting Windows command lines
Treating " as both a delimiter and a literal character means quoted segments are emitted with surrounding quotes (for example, "a b"), which changes argv semantics in --shell=none mode and can make quoted executable paths/arguments behave incorrectly on Windows. The previous shell_words::split behavior removed quote delimiters, so this introduces a regression for commands that rely on quoting only for grouping.
Useful? React with 👍 / 👎.
| if !current.is_empty() { | ||
| tokens.push(current); | ||
| } | ||
|
|
||
| tokens |
There was a problem hiding this comment.
Preserve parse errors for unmatched quotes on Windows
This parser never reports unbalanced quotes, so malformed command lines now silently produce tokens instead of returning the Failed to parse command ... error path used before. In --shell=none, that turns clear input-validation failures into confusing runtime behavior (for example, wrong program tokenization and program not found), which is a user-visible regression from prior parsing semantics.
Useful? React with 👍 / 👎.
Summary
--shell=nonebuilds commands viaCommand::get_command(), which usedshell_words::split.shell_wordstreats\as an escape character, so paths likeDownloads\in.exeare corrupted and fail with "program not found".Fixes #796
Test plan
cargo test(includes unit tests forsplit_command_linepath preservation)hyperfine -N 'Downloads\foo.exe'Note
This complements #876 (forward slash normalization for
cmd.exe). That PR adds overlapping helpers inwindows_cmd.rs; happy to consolidate after either lands.Made with Cursor