I have Cygwin's /bin directory configured to be available on my login
environment PATH by default. This behavior is inherited when I run a
bash login shell:

$ where sort
C:\cygwin\bin\sort.exe
C:\Windows\System32\sort.exe

But if I run the following script from a Windows command prompt:

C:\> bash -c "where sort"
C:\Windows\System32\sort.exe
C:\cygwin\bin\sort.exe

This creates problems when I want to run a bash script from a process
that does not inherit my login environment. Scripts can fail
unexpectedly where identically named binaries from System32 take
priority.

I can't always know what binaries exist in C:\Windows\System32 when
writing my scripts. Am I supposed to always launch scripts as "bash
--login -i -c"? I don't want or need to have bash run all of its login
scripts unnecessarily.

How can I run my bash scripts without invoking it as a login shell and
ensure that /bin has the environment priority over System32 binaries?
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to