Mukesh Jha
Mukesh Jha

Reputation: 934

Running a sh file in git bash even results in variable assignment statements being shown in terminal

I am trying to run a sh file on git bash on Windows 10. I am even seeing the statements which I don't want to be shown like variable assignment in the console. But the same stuff I can't see on either Windows Subsystem for Linux(WSL) or other linux distributions. It becomes a bit annoying to see all the code lines in the sh file when trying to run that, when I am only interested in seeing the statements which I want to echo. Can someone please help in this ?

Sample sh file :

#!/usr/bin/env sh
VARIABLE="OK"
echo $VARIABLE

Output on git bash:

enter image description here

Output on WSL(or any other Linux Systems):

enter image description here

Upvotes: 1

Views: 204

Answers (1)

Zombo
Zombo

Reputation: 1

That only happens when both of these occur:

  1. set -x is used
  2. PS4 is set

If you fix either one, the messages will go away.

If you want to fix number one, you can do set +x, or you can find the file that is calling set -x and remove that line. Probably ~/.bash_profile or ~/.bashrc.

If you want to fix number two, you can do PS4=, and you can add it to one of those files above to persist if you want.

Upvotes: 1

Related Questions