0

I am getting this at the moment when using git bash:

C:\>bash -c pwd
C:\Program Files\Git\bin\bash.exe: line 1: $'MZ\220\003': command not found
/c

When I use the debbuging option, I get this:

C:\>bash -x -c pwd
+ $'MZ\220\003'
C:\Program Files\Git\bin\bash.exe: line 1: $'MZ\220\003': command not found
+ pwd
/c

What is causing this additional $'MZ\220\003' command to be executed?

This is my scenario:

  • Installed git bash from https://git-scm.com/download/win
  • Added "C:\Program Files\Git\bin" to my path, above "Windows\System32" to override the bash in there
  • I can confirm that bash from my cmd session is using the git version
  • I cannot see any .bashrc,.profile or .bash_login entry that could be adding in this command
  • I have another sperate Windows machine with the same setup and the command works fine there
2
  • About MZ: DOS MZ executable. It may be a coincidence MZ appears in the error message you got; or not. Commented Nov 4, 2022 at 17:36
  • MZ is also used for Windows executables (...and UEFI executables), so it's probably that an .exe got accidentally copied to .bashrc, or is being sourced out of .bashrc – use Sysinternals Process Monitor to find out what files are being loaded. Commented Nov 4, 2022 at 19:14

1 Answer 1

1

Fixed the issue. Not sure if this will ever be of use to anyone else, but I will post my findings.

In my windows environment variables I had mistakenly set the BASH_ENV to the path of the bash exe that I was using (C:\Program files\Git\bin\bash.exe). So I think what was happening was:

  1. I run the command bash -c pwd in cmd
  2. cmd finds the git bash exe
  3. git bash exe runs and tries to load vars from BASH_ENV
  4. It finds a path to itself tries to run it?

Weird thing was it actually tried to look for an executable called MZ* .exe in a number of different directories before erroring out. Proc mon shows:

Process monitor screenshot

Also probing the environment, the bash exe showed:

_=$$'MZ\220\003'

Not sure at to the inner workings here, but ultimately deleting that env var solved my issues and I can finally use it as normal (whew...)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .