From a13c18d4f15ad858c345ee3cb72f5c2bda08bf1c Mon Sep 17 00:00:00 2001 From: muvahhid kilic Date: Fri, 6 Nov 2026 21:54:07 +0300 Subject: [PATCH 1/2] Pass //-escaped switches to native programs with one slash MSYS strips one slash from an argument that starts with // before passing it to a native program, which is how Windows switches survive path conversion (cmd //c, taskkill //F). gash passed them on unchanged, so cmd //c echo hi started an interactive cmd. convert_arg now matches Git Bash: //c becomes /c and ///x becomes //x, while UNC-like arguments such as //server/share are left alone. Co-Authored-By: Claude Opus 5.5 --- src/path.rs | 8 ++++++++ tests/scripts/067_double_slash_switches.code | 1 + tests/scripts/067_double_slash_switches.out | 3 +++ tests/scripts/067_double_slash_switches.sh | 7 +++++++ 4 files changed, 19 insertions(+) create mode 100644 tests/scripts/067_double_slash_switches.code create mode 100644 tests/scripts/067_double_slash_switches.out create mode 100644 tests/scripts/067_double_slash_switches.sh diff --git a/src/path.rs b/src/path.rs index be1bba5..f5017b0 100644 --- a/src/path.rs +++ b/src/path.rs @@ -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" { diff --git a/tests/scripts/067_double_slash_switches.code b/tests/scripts/067_double_slash_switches.code new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/tests/scripts/067_double_slash_switches.code @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/tests/scripts/067_double_slash_switches.out b/tests/scripts/067_double_slash_switches.out new file mode 100644 index 0000000..82cc441 --- /dev/null +++ b/tests/scripts/067_double_slash_switches.out @@ -0,0 +1,3 @@ + '/c' '/F' '//x' '//server/share/x' '//c/x' '/' +switch passed + '//c' diff --git a/tests/scripts/067_double_slash_switches.sh b/tests/scripts/067_double_slash_switches.sh new file mode 100644 index 0000000..c57fffc --- /dev/null +++ b/tests/scripts/067_double_slash_switches.sh @@ -0,0 +1,7 @@ +# 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`. +git rev-parse --sq-quote //c //F ///x //server/share/x //c/x // +cmd //c echo switch passed +export MSYS_NO_PATHCONV=1 +git rev-parse --sq-quote //c +unset MSYS_NO_PATHCONV From b4e1fc3c4b684e26e6b92a1da377b5c626d43bd8 Mon Sep 17 00:00:00 2001 From: muvahhid kilic Date: Fri, 6 Nov 2026 23:04:18 +0300 Subject: [PATCH 2/2] Make 067 independent of exported path-conversion settings The script expected conversion on, so it failed when MSYS_NO_PATHCONV or MSYS2_ARG_CONV_EXCL was already exported, as Claude Code does, and cmd //c then started an interactive cmd. It now unsets both first. Co-Authored-By: Claude Opus 5.5 --- tests/scripts/067_double_slash_switches.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/scripts/067_double_slash_switches.sh b/tests/scripts/067_double_slash_switches.sh index c57fffc..7cd3f70 100644 --- a/tests/scripts/067_double_slash_switches.sh +++ b/tests/scripts/067_double_slash_switches.sh @@ -1,5 +1,7 @@ # 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 // cmd //c echo switch passed export MSYS_NO_PATHCONV=1