Skip to content

fix: preserve Windows backslashes with --shell=none#884

Open
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:fix/shell-none-windows-backslashes-796
Open

fix: preserve Windows backslashes with --shell=none#884
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:fix/shell-none-windows-backslashes-796

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

  • --shell=none builds commands via Command::get_command(), which used shell_words::split.
  • On Windows, shell_words treats \ as an escape character, so paths like Downloads\in.exe are corrupted and fail with "program not found".
  • Use a Windows-aware splitter that preserves backslashes when tokenizing the command line for raw execution.

Fixes #796

Test plan

  • cargo test (includes unit tests for split_command_line path preservation)
  • Manual verification on Windows: hyperfine -N 'Downloads\foo.exe'

Note

This complements #876 (forward slash normalization for cmd.exe). That PR adds overlapping helpers in windows_cmd.rs; happy to consolidate after either lands.

Made with Cursor

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>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/util/windows_cmd.rs
Comment on lines +18 to +21
'"' => {
in_double_quotes = !in_double_quotes;
current.push(ch);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread src/util/windows_cmd.rs
Comment on lines +32 to +36
if !current.is_empty() {
tokens.push(current);
}

tokens
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

Running with --shell=none fails with Windows paths containing backslashes (\), works with forward slashes (/)

1 participant