0

I have a folder for my .bat and .sh files.
This folder is part of my PATH. I can run the .bat files without any problems using the command prompt. But I can't run the .sh files with git bash.
I have made the scripts executable, and if I'm in the folder where the scripts are then I can run them with ./myScript.sh for example, without any trouble.
If I echo the PATH variable I git bash shows that the scripts folder is included.
If I run which myScript.sh I get /c/opt/scripts/myScript.sh
So what am I missing?

Also, I'd really like to run it with just myScript instead of ./myScript.sh is that possible?

1 Answer 1

2

Find the .bashrc file. In my case it was in C:\Program Files\Git\etc and it was actually called bash.bashrc

In the bottom of that file I added the following:

alias myScript=\'/c/opt/scripts/./myScript.sh\'

This solved both my issues. I can now run the script from anywhere simply by typing myScript

Sign up to request clarification or add additional context in comments.

1 Comment

just in case if you do not know: the reason of such behavior is securuty, so writing ./ prefix is really saying "yes, I want to run it, please first look up in current folder", so suppressing a search in PATH.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.