Repository navigation
Find sh on the PATH when running under Git Bash or MSYS2 on Windows - #2289
Merged
Merged
Conversation
With MSYSTEM set, GetShellRunArray returned "/bin/sh", which mlr.exe, a native Windows program, cannot resolve. So system(), --prepipe and piped redirects failed with "fork/exec /bin/sh: The system cannot find the path specified." Look sh up on the PATH instead, falling back to cmd. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
MSYSTEMis set (Git Bash, MSYS2),GetShellRunArrayreturns/bin/sh. mlr.exe is a native Windows program and can't resolve that MSYS path, so everything that shells out fails from Git Bash:Piped redirects (
tee | "cat", $*) go through the same function. This looksshup on the PATH instead (Git Bash and MSYS2 put theirusr/binthere) and falls back tocmd /cif it isn't found.exec.LookPathreturns an absolute path, whichos.StartProcessinhalfpipe.goneeds.Added a Windows-only test in
pkg/platformthat setsMSYSTEMand runsecho hellothrough the result; it fails before the change and passes after (skipped when there's noshon the PATH).TestRunAllowShellinpkg/terminals/mcpalso failed from Git Bash before this.mlr regtestfrom Git Bash still needs the mlr path with forward slashes in thesh -cline; I left that out to keep this small.