fix: support relative forward-slash paths on Windows - #909
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c3990fa05
ℹ️ 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".
| // `cmd.exe /C` treats the leading `.` as a command when passed | ||
| // verbatim. Normalize only the executable path and let `Command` | ||
| // quote the complete invocation. | ||
| command_builder.arg(normalize_relative_command_path_for_cmd(&command_line)); |
There was a problem hiding this comment.
Preserve raw cmd quoting for relative commands
On Windows, this branch switches cmd.exe /C from raw_arg to arg whenever the benchmark starts with ./ or ../. For a command such as ./tool.exe "input file.txt", Rust applies C-runtime escaping to the inner quotes (for example \"...\"), but cmd.exe /c has different escaping rules—the Rust raw_arg docs call out this exact case: https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.raw_arg. The result is that quoted arguments after a relative executable can be split or delivered with literal quotes/backslashes; normalize the executable path but keep appending the resulting command string with raw_arg so existing quoted-command behavior is preserved.
Useful? React with 👍 / 👎.
Summary
cmd.exe /CFixes #818
Root cause
The default Windows executor appended the full command line with
raw_arg(). For a command beginning with./or../,cmd.exeinterpreted the leading.as a command instead of a relative path.Validation
cargo fmt -- --checkcargo clippy --locked --all-targetscargo test --locked normalizes_only_the_relative_executable_pathcargo test --locked windows_runs_executable_paths_with_forward_slashescargo test --locked windows_quote_argscargo test --lockedexercises the new regression and 34 of 36 integration tests on Windows. The remaining two integration tests invoke Unix shell syntax (echo '...'andsleep) without a Windows guard; they are unrelated to this change.