I have script foo.sh
in my Cygwin directory /usr/local/bin
. I can run it using mintty
, but not using bash.
When I started, the situation was as follows:
foo.sh in mintty - WORKING
foo.sh in bash - NOT WORKING
Then I added line export PATH="${PATH}:/usr/local/bin"
to my .bashrc
file. Now situation is as below:
foo.sh in mintty - WORKING
foo.sh in bash - WORKING
however
bash -c foo.sh - NOT WORKING
I need the last method of running the script to work. I will use it in my executable, which is compiled for Windows, so the command musts work in cmd
.
My questions are:
- How to set variable
PATH
, to work withbash -c
. - Why
/usr/local/bin
is not inPATH
by default? Is it any reason to don't do that I'm trying to do?
The
.bashrc
file is only executed for non-login shells. For environments like this, I recommend including.bashrc
from.bash_profile
:This way, your
.bashrc
will be included for both login and non-login shells.