Start bash shell (cygwin) with correct path without changing directory
It turns out that the cygwin default /etc/profile
checks for an environment variable named CHERE_INVOKING
and inhibits the change of directory if set.
So
set CHERE_INVOKING=1
\path\to\bash.exe -l -c command
has the desired behavior.
Related videos on Youtube
![Ben Voigt](https://i.stack.imgur.com/rX1ss.png?s=256&g=1)
Ben Voigt
Rainbow logo and associated message do not reflect my views, they've been unilaterally placed next to my name by Stack Exchange, Inc. Currently seeing what can be done about this, discussion at http://meta.stackoverflow.com/q/298004/103167 Since Stack Exchange has effectively turned my profile page into a political platform without my foreknowledge or consent, I feel obligated to share my own views: An oligarchy of five justices setting policy for the entire USA is not the government the Constitution guarantees, and it's not the one we want. Not everything President Gerald Ford said was very smart or worth repeating, but this is A government big enough to give you everything you want is a government big enough to take from you everything you have. The USA was designed as a Constitutional Republic, with checks-and-balances between the branches of the federal government, and also division of power between federal state and local governments. (And these are explicitly required by the plain language of the Constitution) All government officials need to stay within the authority granted to them by the Constitution, especially when that means they can't do whatever they want.
Updated on September 18, 2022Comments
-
Ben Voigt almost 2 years
I need to run a cygwin shell script without changing the working directory, from outside the cygwin environment.
If I run just
\path\to\bash.exe -c command
, then the path is not set correctly and cygwin programs can't be found.If I use the
--login
option,bash
sets the path correctly, but also changes to my home directory.What options should I use to launch bash to keep the current working directory, and also find cygwin executables?
-
faisalala over 9 yearsThis works for invoking MSYS2 bash as well.