Repository navigation
Conversation
📊 Automated PR Analysis
SummaryFixes how rtk detects batch files (.bat/.cmd) on Windows for the purpose of deciding whether to leave arguments on std's encoder. Instead of checking the extension of the raw program name, it now resolves the path the same way Windows/std does (via std::path::absolute, with special-casing for verbatim \?\ and ??\ prefixes) before checking the suffix, fixing cases like trailing dots/spaces or path traversal components. Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
std runs a program through cmd.exe as a batch file when the path Windows resolves it to ends in `.bat` or `.cmd`: GetFullPathNameW drops trailing dots and spaces and folds `.` and `..`, and a verbatim path is tested as written. `is_batch_program` read the extension of the name as given, so `x.bat.`, `x.bat `, `x.bat\.` or a file named `.cmd` were not treated as the batch files std runs. It now resolves the path with `std::path::absolute`, the same call, and applies std's suffix test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
85524e2 to
c3b2527
Compare
|
Closing in favour of #4103, which now carries this change. #4103 replaces |
Summary
On Windows,
child_argleaves the arguments of a batch file on std's encoder, since cmd.exe parses them by its own rules.is_batch_programdecided that from the extension of the program name as given, while std decides it from the path Windows resolves:GetFullPathNameWdrops trailing dots and spaces and folds.and.., and std then checks for a.bat/.cmdsuffix (a verbatim\\?\or\??\path is checked as written). This makes rtk ask the same question: resolve withstd::path::absolute, which is that call, then apply std's suffix test.Behaviour change (Windows)
x.bat.,x.bat,x.bat\.or a file named.cmdis now treated as the batch file std runs, so its quoted arguments stay on std's encoder.Test plan
has_batch_suffix(std's suffix test) is asserted on every platform.test_child_arg_leaves_batch_shims_on_stds_encodingnow coversx.bat.,x.bat,x.bat. .,x.bat\.and.cmd;test_batch_program_follows_the_path_windows_resolvescoversx.bat\.., verbatim\\?\and\??\paths, andx.exe.cargo fmt --all -- --check,cargo clippy --all-targetsandcargo test --allpass on Linux; a Windowscargo check --all-targetspasses.🤖 Generated with Claude Code