public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* How to ensure that /bin takes priority over System32 with "bash -c"?
@ 2020-10-31 13:16 Matt D.
  2020-10-31 14:21 ` Adam Dinwoodie
  0 siblings, 1 reply; 3+ messages in thread
From: Matt D. @ 2020-10-31 13:16 UTC (permalink / raw)
  To: cygwin

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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-31 19:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-31 13:16 How to ensure that /bin takes priority over System32 with "bash -c"? Matt D.
2020-10-31 14:21 ` Adam Dinwoodie
2020-10-31 19:46   ` Brian Inglis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).