www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/10/31/09:17:12

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87CFC384A030
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1604150189;
bh=R2PzDK/SZHqMH6fOEbmpiDZctKYB/lHKdyCWEHaf6sk=;
h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=N8vnxrpS13l/kN6nlW7whcu+/s5HW7h5+hfMqO4wj9Ut8jZ3vAr96rP7Tgwy3ntJW
42txISBED7tnYFxQaddP6X8MU1+u2Xho+YWaVlmaDsBvpp//Khy43J0kZ6/wPDNXH4
3zp2VHGEmxmNjluMNp4C2kkPsL2a6LG9TZDQd0M4=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DCF3B3861038
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=MlbZA545VUrhM6H4Nia0ShA8d+9XX7HSTaKPKi+bHmU=;
b=mFcm8CaDWugnus7BxjWUFiWItpuFM8n++ho9nO0mlsOk8TSE1z7DfneRXBrPpNdEpr
cQuVUdxa0eieB2TA0ARSMMJPVpv2+k4JBcucjaigYOkqxQTkX2pGiM+YDlybLk2hrpZA
ct9iQm73CvK9YW/mz6cwwb4R+v8CaEE9I5eON+LG8sGWQDyjwKIy/KkWbB0ovOrFOQyw
kOm+aCG57V2vLdJ0I/27AAarWOcb5PBuz5fa1AHULCiyIbNvmPY0nYIluQuLjxtvKa/o
W89j0o4X3hSWw042AT1LXYVokpuDIzfIqRMZmst3zCqMkFzWuM88sulHYc5nmylIH22c
GW3w==
X-Gm-Message-State: AOAM5308HrUxyfKSdXfMc/qyXwyNBIAjPq0ARnaUZWRExM9NtSUB2wEH
WwO7ZyYJb53qrqz+aeoBIO3HJPpH48PwAY+z7Z+xkZGuypM=
X-Google-Smtp-Source: ABdhPJzlVnjtzWwxR5Gyk+FG6219cDEGLeaEEaJSB6hgjhOAuFFCHf550ZiPenAlFiqsxYwX1vVg4Uo2N2zm+Bg7AsE=
X-Received: by 2002:a05:6512:47c:: with SMTP id
x28mr145820lfd.321.1604150185302;
Sat, 31 Oct 2020 06:16:25 -0700 (PDT)
MIME-Version: 1.0
Date: Sat, 31 Oct 2020 09:16:13 -0400
Message-ID: <CAC+X2=+bkYcN9Qv1kUNom3q3Ljek=Xw888QW-ueYipX3WrKphg@mail.gmail.com>
Subject: How to ensure that /bin takes priority over System32 with "bash -c"?
To: cygwin AT cygwin DOT com
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: "Matt D. via Cygwin" <cygwin AT cygwin DOT com>
Reply-To: "Matt D." <codespunk AT gmail DOT com>
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019