delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/01/02/12:15:10

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 502HF9di4067580
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 502HF9di4067580
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=amtF7PWf
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00C433858CDA
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1735838109;
bh=QOtEbuyNMpgts5W3HPWd8nnCNIcwH9CaR2hP5nAflQ0=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
From;
b=amtF7PWf+nyS0+FY6ESO4FxwTOS1n49qDIDFdcqu1d5atZmRLUctW2bon298Zmt02
vrauNN++R4AH/O0PY1lzRbhT1ut/qCprczfw7+NCFyeZeDAAMtko7MPOYKj7hLGdrd
h3Z0jTVw8CXqhhsv33K6LgY4ijN5fE9BGc4P2Nmg=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2DCC13858D33
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2DCC13858D33
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735838041; cv=none;
b=UxHyeNXYS42nUVV1OcDw4wN9Fso2mecMDZ1hOAbh7wPF9V428gMcLOMtYgUcgO4naRhnSENN7VzSvyNdp5hJECWKeAK1pHLQWQRsBKulz4RhKrAvbJtlJ7G5GlkFHU2rqGd81QghCdvCQ4EVh/aBXJz3LxSUEcom9WwpxOTCcNo=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1735838041; c=relaxed/simple;
bh=aDVetUDHTklCwQPrzFKu7IA5Vwes/2gTCvyn+QspEzU=;
h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To;
b=Q5onjk8op6fJT5cmwnhjxAk6rv72D7fzoxfxJH+04FmuNwjMLkpvWoUPTQjLQWECiH7KR+NvIWEZCIYQo/JEN76bkokucBSJ770iBCHbAcezJuoZ9XZWdePCcx0178Zef9QgCWPr2A09/ieA5nxrcKEXdyrZbaCqSUQyxF8LgtQ=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DCC13858D33
Message-ID: <cd5b9101-58d9-48ea-8e85-b7334737d16c@kircheis.it>
Date: Thu, 2 Jan 2025 18:13:55 +0100
MIME-Version: 1.0
Subject: Re: env and PATH
To: cygwin AT cygwin DOT com
References: <77a3709d-ec4d-497b-bf6c-75f29dc8c992 AT kircheis DOT it>
<b04cbe33-2461-448d-bce7-39a703ece625 AT SystematicSW DOT ab DOT ca>
<8ec51c94-fdb0-4fb1-8d89-97e5c513f5ed AT kircheis DOT it>
In-Reply-To: <8ec51c94-fdb0-4fb1-8d89-97e5c513f5ed@kircheis.it>
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
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: Federico Kircheis via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Federico Kircheis <federico AT kircheis DOT it>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 502HF9di4067580

On 02/01/2025 10.34, Federico Kircheis wrote:
> On 20/12/2024 23.15, Brian Inglis via Cygwin wrote:
>> Hi Federico,
>>
>> Looks like non-Cygwin program launch is messing up PATH not on the 
>> current drive:
>>
>> $ cd /proc/cygdrive/d
>> $ cat -A /proc/cygdrive/d/tmp/t.cmd
>> echo %PATH%^M$
>> $ env -i PATH='C:\Windows;C:\Windows\system32;' /bin/sh -c 'echo $PATH'
>> C:\Windows;C:\Windows\system32;
>> $ env -i PATH='C:\Windows;C:\Windows\system32;' `cygpath $COMSPEC` / 
>> s /c \
>> "d:\tmp\t.cmd"
>> D:\>echo C;D:\Windows;C;D:\Windows\system32;
>> C;D:\Windows;C;D:\Windows\system32;
>> D:\>exit
> 
> I did some other testing
> 
>  From cygwin, without using env explicitly
> 
>  > PATH='D:\windows' /c/Windows/System32/WindowsPowerShell/v1.0/ 
> powershell.exe
>  > echo $env:PATH
> D;C:\windows
> 
> (similar result for cmd)
> 
>  From powershell
> 
>  > $env:PATH="D:\windows"
>  > C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
>  > echo $env:PATH
> D:\windows
> 
> (similar result for cmd)
> 
> I also tried
> 
> PATH='D:\windows' /usr/bin/cygstart /c/Windows/System32/ 
> WindowsPowerShell/v1.0/powershell.exe
> 
> hoping it would do the trick, but PATH is still "broken", and powershell 
> starts in a separate window :(

And obvisouyl I also tried

 > PATH="/cydrive/c/windows:/cygdrive/d/windows" 
/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
 > echo $env:PATH
C:\Windows;D:\Windows

So it still looks like cygwin translates the paths when creating a new 
process.

 From powershell
 > $env:PATH="/d/windows"
 > C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
 > echo $env:PATH
/d/windows

which seems to imply that powershell (and cmd) gets the environment 
variable PATH as-is


> 
>>
>> On 2024-12-20 09:51, Federico Kircheis via Cygwin wrote:
>>> Hello to everyone,
>>>
>>>
>>> I've noticed that env seems to handle the environment variable PATH 
>>> in a particular way
>>>
>>>
>>> -----
>>>  > cd /d;
>>>  > env -i PATH='C:\Windows;C:\Windows\system32;' /c/Windows/System32/ 
>>> WindowsPowerShell/v1.0/powershell.exe
>>> # in the powershell instance
>>> echo $env:PATH
>>> C;D:\Windows;C;D:\Windows\system32;
>>> ----
>>>
>>>
>>>  From this and other examples it seems that env uses for PATH  as 
>>> separator, then preprends the current drive to all paths that begin 
>>> with '\' (thus all of them), and ";" is treated as part of the path
>>>
>>>
>>> I would like to use the PATH as-is in the invoked program, just like 
>>> it is done for other variables, for example
>>>
>>> ----
>>> cd /d
>>> env -i OPATH='C:\Windows;C:\Windows\system32;' /c/Windows/System32/ 
>>> WindowsPowerShell/v1.0/powershell.exe
>>> # in the powershell instance
>>> echo $env:OPATH
>>> C:\Windows;C:\Windows\system32;
>>> ----
>>>
>>> in this case OPATH is forwarded as-is to powershell.exe.
>>>
>>> I understand that PATH is special, that for cygwin processes some 
>>> transformation might be necessary.
>>>
>>> But is there any way to achieve what I'm trying?
>>>
>>> I search if there is maybe a separation option for telling env to use 
>>> PATH as- is, but could not find none.
>>>
>>> Best
>>>
>>> Federico


-- 
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