Greetings, Federico Kircheis!

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

Fully expected behavior. `env` expects POSIX semantics and parsed your
command according to that.
The results are, as I said, expected, although not by you.

>  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

Exactly.

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

It is, but in a way you suppose.

> But is there any way to achieve what I'm trying?

Yes. Pass the POSIX paths in $PATH, they will be converted to Windows ones
when invoking a Windows process.
Also, I strongly suggest using /proc/cygdrive/ tree in such case, especially
when you make scripts for somebody else.

> I search if there is maybe a separation option for telling env to use PATH 
> as-is, but could not find none.

There's no need or reason to do it.

In your case, what you wanted to achieve could be written as

>> env -i "PATH=$(cygpath -UW):$(cygpath -US):$PATH" pwsh

(The "%SystemRoot%" is NOT NECESSARILY 'C:\Windows', though you CAN use
"%SystemRoot%\System32" with confidence, once you acquired the former.)
(Also, why the *** you are using v1.0? Get v7 already, save yourself the
tragedy.)


-- 
With best regards,
Andrey Repin
Saturday, January 4, 2025 04:28:52

Sorry for my terrible english...


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