Running .sh scripts in Git Bash
#!/usr/bin/env sh
this is how git bash knows a file is executable. chmod a+x
does nothing in gitbash. (Note: any "she-bang" will work, e.g. #!/bin/bash
, etc.)
Let's say you have a script script.sh
. To run it (using Git Bash), you do the following: [a] Add a "sh-bang" line on the first line (e.g. #!/bin/bash
) and then [b]:
# Use ./ (or any valid dir spec):
./script.sh
Note: chmod +x
does nothing to a script's executability on Git Bash. It won't hurt to run it, but it won't accomplish anything either.