Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ pub fn convert_arg(arg: &str) -> Cow<'_, str> {
if arg.len() < 2 {
return Cow::Borrowed(arg);
}
// `//x` is an escaped Windows switch (`cmd //c`, `taskkill //F`): as in MSYS, it loses one
// slash, unless it looks like a UNC path (`//server/share`).
if let Some(rest) = arg.strip_prefix("//") {
if rest.is_empty() || rest.starts_with('/') || !rest.contains('/') {
return Cow::Owned(arg[1..].to_string());
}
return Cow::Borrowed(arg);
}
let cwd = Path::new("C:\\");
if convertible(arg) {
if arg == "/dev/null" {
Expand Down
1 change: 1 addition & 0 deletions tests/scripts/067_double_slash_switches.code
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
3 changes: 3 additions & 0 deletions tests/scripts/067_double_slash_switches.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'/c' '/F' '//x' '//server/share/x' '//c/x' '/'
switch passed
'//c'
9 changes: 9 additions & 0 deletions tests/scripts/067_double_slash_switches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# An argument starting with // is an escaped Windows switch: a native program gets it with one
# slash fewer, as with MSYS (`cmd //c`, `taskkill //F`), unless it looks like `//server/share`.
# Start from no conversion settings, whatever the environment exports (Claude Code sets one).
unset MSYS_NO_PATHCONV MSYS2_ARG_CONV_EXCL
git rev-parse --sq-quote //c //F ///x //server/share/x //c/x //

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Test isn't hermetic. If MSYS_NO_PATHCONV=1 is already exported when the suite runs, this line gets no conversion and the script fails. Claude Code exports it, and some Git for Windows setups do too. With the variable unset, it passes. Suggestion: start the script with unset MSYS_NO_PATHCONV MSYS2_ARG_CONV_EXCL. Or, to fix this for every script, add both names to REMOVED_ENV in tests/compat.rs and to regen_expected.ps1.

In that state, cmd //c echo on line 4 also starts an interactive cmd, because //c reaches it unconverted.

cmd //c echo switch passed
export MSYS_NO_PATHCONV=1
git rev-parse --sq-quote //c
unset MSYS_NO_PATHCONV
Loading