Repository navigation
Pass //-escaped switches to native programs with one slash, as MSYS does - #11
Conversation
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 <noreply@anthropic.com>
582a313 to
a13c18d
Compare
hex2f
left a comment
There was a problem hiding this comment.
Thanks for this. The conversion matches Git Bash. One thing about the test, line comment below.
I merged it onto current main. When MSYS_NO_PATHCONV isn't set, the new script matches the Git Bash output and the rest of the suite passes.
| @@ -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 // | |||
There was a problem hiding this comment.
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.
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 <noreply@anthropic.com>
|
Thanks! Fixed: the script now starts with |
|
Thanks, that fixes it. I merged b4e1fc3 onto current main and it merges cleanly. With |
Found by running the same commands through Git Bash and gash side by side.
MSYS strips one slash from an argument that starts with
//before passing it to a native program. That is how Windows switches get through path conversion:cmd //c echo hi,taskkill //F //PID 123,schtasks //query. gash passed them on unchanged, socmd //c echo histarted an interactivecmdinstead of running the command.convert_argnow does what Git Bash does://c→/c,//F→/F,///x→//xand//→/, while UNC-like arguments (//server/share/x,//c/x) are left alone. As before, nothing is converted whenMSYS_NO_PATHCONVis set.Tests
067_double_slash_switches.sh, with expected output from Git Bash 5.3.15 viaregen_expected.ps1. It fails without the change and passes with it.cargo testpasses: unit tests, 62/62 compat scripts andmsys_tmp.