Skip to content

Honor MSYS_NO_PATHCONV given as a command prefix, and add pwd -W - #10

Merged
hex2f merged 2 commits into
hex2f:mainfrom
ExpectedArgument:msys-pathconv-prefix-pwd-w
Nov 6, 2026
Merged

hex2f merged 2 commits into
hex2f:mainfrom
ExpectedArgument:msys-pathconv-prefix-pwd-w

Conversation

@ExpectedArgument

@ExpectedArgument ExpectedArgument commented Nov 6, 2026 •

Copy link
Copy Markdown

Two small gaps with Git Bash that turned up while testing #1–#3.

MSYS_NO_PATHCONV and MSYS2_ARG_CONV_EXCL

run_external read them from shell variables only. So the usual prefix form (MSYS_NO_PATHCONV=1 docker run -v /c/src:/src ...) was ignored, while an unexported MSYS_NO_PATHCONV=1 did count. Git Bash's MSYS runtime sees them in the environment a program starts with, so they now count when exported or given as a prefix, and not as plain shell variables.

pwd -W

MSYS bash's pwd -W prints the physical directory in Windows form (C:/Windows/System32). gash ignored -W and printed the MSYS path; it now supports it. As in Git Bash, -L, -P and -W can be combined and the last one wins (pwd -LW prints the Windows form, pwd -WP the MSYS one), and an invalid option is reported with exit status 2.

Tests

  • New compat script 072_pathconv_env_pwd_w.sh, with expected output from Git Bash 5.3.15 via regen_expected.ps1. For the conversion it uses git rev-parse --sq-quote as a native program that echoes its arguments, with no variable, a prefix, an unexported and an exported variable, and MSYS2_ARG_CONV_EXCL both as a prefix and exported. For pwd it covers -W, -LW, -WP, -P, -L and an invalid option. It fails with v0.1.0 and passes with this branch.
  • cargo test passes: unit tests, 66/66 compat scripts and msys_tmp.
  • README updated.

run_external read MSYS_NO_PATHCONV and MSYS2_ARG_CONV_EXCL from shell
variables only, so the usual prefix form (MSYS_NO_PATHCONV=1 cmd ...)
was ignored while an unexported variable did count. Like Git Bash's MSYS
runtime, they now count when exported or given as a prefix.

pwd -W prints the physical directory in Windows form (C:/...), as MSYS
bash does. -L, -P and -W combine and the last one wins, and an invalid
option is reported with exit status 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ExpectedArgument
ExpectedArgument force-pushed the msys-pathconv-prefix-pwd-w branch from c8e3248 to 8e3225e Compare November 6, 2026 19:35

@hex2f hex2f left a comment

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.

Thanks for this. The env/prefix handling and pwd -W both match 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.

Behaviour change (FYI): a plain unexported MSYS_NO_PATHCONV=1 no longer turns off conversion. That's correct and matches Git Bash, but it's worth a line in the release notes, since it can break someone's .bashrc.

@@ -0,0 +1,22 @@
# MSYS_NO_PATHCONV and MSYS2_ARG_CONV_EXCL count when exported or given as a command prefix,
# as in Git Bash. pwd -W prints the current directory in Windows form.
git rev-parse --sq-quote /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.

With the variable exported, lines 3 and 5 of the script both print '/c/x' where 'C:/x' is expected.

The script expected conversion on, so it failed when MSYS_NO_PATHCONV or MSYS2_ARG_CONV_EXCL was already exported, as Claude Code does. It now unsets both first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ExpectedArgument

Copy link
Copy Markdown
Author

Thanks! Fixed: the script now starts with unset MSYS_NO_PATHCONV MSYS2_ARG_CONV_EXCL. With MSYS_NO_PATHCONV=1 and MSYS2_ARG_CONV_EXCL=* exported, cargo test passes (66/66 compat scripts), and so it does with them unset. Git Bash gives the same expected output in both cases.

@hex2f

hex2f commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Thanks, that fixes it. I merged df22526 onto current main, which now includes #6 and #9, and it merges cleanly. With MSYS_NO_PATHCONV=1 still exported, cargo test passes 71/71. Together with #11 and #21 it passes 72/72, with the conversion variables exported, unset, and with MSYS2_ARG_CONV_EXCL=*. No new clippy warnings. Looks good to merge.

@hex2f
hex2f merged commit 881e1ad into hex2f:main Nov 6, 2026
1 check passed
ExpectedArgument pushed a commit to ExpectedArgument/gash that referenced this pull request Nov 6, 2026
It sat right after `msys_child`, where hex2f#10 also adds lines, so the two
changes conflicted. Declared a few lines up, they merge in either order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants