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