10

From what I understand bin\bash.exe invokes usr\bin\bash.exe I guess with some options to help manage windows paths but can't find any documentation to indicate that.

All I know is my scripts seem not to work as expected if I have my environment set to use Git\usr\bin\ rather than Git\bin.

A new dev box seems to have this setup:

where bash

C:\Windows\System32\bash.exe

C:\Program Files\Git\usr\bin\bash.exe

I can understand wsl being top but can't understand the second entry if bin/bash.exe is the one I am supposed to use?

3

2 Answers 2

6

%windir%\system32\bash.exe = inline bash shell hosted by whatever windows subsystem for linux [ wsl ] environment you have enabled using microsoft store | windows subsystem for linux | | install. An alternative but essentially same result as the separate window that start menu shortcut %windir%\system32\wsl.exe ~ -d Ubuntu launches.

%programfiles%\git\bin\bash.exe -> %programfiles%\git\usr\bin\bash.exe + some automatically injected arguments = inline [ main stdin/stdout ] bash shell provided by git layered on top of windows cmd.exe command prompt environment

%programfiles%\git\git-bash.exe = windows app [ winmain ] bash shell provided by git layered on top of windows cmd.exe command prompt environment

7
  • Thanks for the reply! As I mentioned my scripts only seem to work if I use: "C:\Program Files\Git\bin\bash.exe" - so I guess I need to understand what these "+ some automatically injected arguments" are... Is this documented anywhere? Did look on the git-for-windows github but couldn't see anything. Commented Sep 17, 2019 at 14:45
  • 1
    I don't know. I ran %programfiles%\Git\bin\bash.exe and then under process details looked at command line and i see that it spawns a %programfiles%\Git\bin\..\usr\bin\bash.exe w/o any command line arguments so the document i saw referring to "+ some automatically injected arguments" is perhaps referring to internally defined arguments in that exe given its 1918KB vs the bin\bash.exe that is 44KB.
    – myusrn
    Commented Sep 18, 2019 at 16:13
  • On my system attempting to running %programfiles%\Git\usr\bin\bash.exe directly produces output bash: cut: command not found and attempts to use printenv, in effort to compare environment differences launching this way vs using Git\bin\bash.exe, produces bash: printenv: command not found.
    – myusrn
    Commented Sep 18, 2019 at 16:22
  • 2
    Running the alternative %programfiles%\Git\bin\git-bash.exe i see that it spawns usr\bin\mintty.exe --nodaemon -o AppID=GitForWindows.Bash -o AppLaunchCmd="%programfiles%\Git\git-bash.exe" -o AppName="Git Bash" -i "%programfiles%\Git\git-bash.exe" --store-taskbar-properties -- /usr/bin/bash --login -i to setup the new command window followed by %programfiles%\Git\usr\bin\bash.exe.
    – myusrn
    Commented Sep 18, 2019 at 16:22
  • layered on top of windows cmd.exe command prompt environment is it? It runs bash.exe on top of mintty.exe but does it also involve cmd.exe?
    – CervEd
    Commented May 27, 2021 at 9:36
4

So it appears that:

"C:\Program Files\Git\usr\bin\bash" -li

yields:

Me@MYPC MSYS /usr/bin

and

"C:\Program Files\Git\bin\bash" -li

yields:

Me@MYPC MINGW64 /usr/bin

So to my eyes that implies the EXE are compiled differently.

But in my case the issues I was having with my scripts was purely down to the PATH each exe sets up:

For

"C:\Program Files\Git\usr\bin\bash.exe"

$ where FIND C:\Windows\System32\find.exe C:\Program Files\Git\usr\bin\find.exe

Whereas:

"C:\Program Files\Git\bin\bash.exe"

$ where FIND C:\Program Files\Git\usr\bin\find.exe C:\Windows\System32\find.exe

So my script in the former case was failing with a

FIND: Parameter format not correct

as it wasn't finding the correct version of find.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.