DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 5041oaHw1547767 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 5041oaHw1547767 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=VXEoevkx X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF6A63858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1735955435; bh=HjaN1a0254Qxr/H/ye8qGfppPID7ukbjMzyOsPMR0oc=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=VXEoevkxWWLqp++I7fjDjO/Epy/5BeXrhy4GXAUZpcSouG77F75e2Y3eJzQRidHFj 0iNPDLjILfa/nkuBiu3vbxtJtQcK9TGi+53AJbYpCAXbu7zz2/hWw0+vq6iddOREqA 0HCZZdT/wezQ6VIL2QxjKlYjR3Gbzz8JwM5Lau4U= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A87DE3858D20 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A87DE3858D20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735955402; cv=none; b=l+pJH9CZ4VY/G7+0paPl75slqNbbMGhajIWzzQ6ZCyfuFFv4G6PDqW7CRRyFtvTMVYcJMbyBeR4eMYHup6M9gtQ8TrlSy6W3PFDa9e9ecxn+XsaETmdQqnm+ppj2yxH0bpI/KQH54Um6yvjiIIcocT9cuhChx/YZnyJVXg5xoDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1735955402; c=relaxed/simple; bh=3nWZCWmx077WDf/P/bNf5vqeUhg+sD7hz+FErbRwI+Y=; h=DKIM-Signature:Date:From:Message-ID:To:Subject:MIME-Version; b=hvB26OabHt3+LSs4TxP+CUYVsjVwrq8UtDgIzP1eHsS1GqtWrUe+BWPgqJHsjslRtaP/zreaRWBZAOJdHMN4o+5mJ3/0eEqCSUOUw31FLtkmieuNtwedvg0bDbb9phcHSUK639oB/9+Jl4ETB5agJBfI2jtqpSBjZdMtFAyFgkM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A87DE3858D20 X-Yandex-Fwd: 1 Date: Sat, 4 Jan 2025 04:41:39 +0300 X-Mailer: The Bat! (v9.3.4) Professional Message-ID: <1756102695.20250104044139@yandex.ru> To: Federico Kircheis , cygwin AT cygwin DOT com Subject: Re: env and PATH In-Reply-To: <77a3709d-ec4d-497b-bf6c-75f29dc8c992@kircheis.it> References: <77a3709d-ec4d-497b-bf6c-75f29dc8c992 AT kircheis DOT it> MIME-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrey Repin via Cygwin Reply-To: cygwin AT cygwin DOT com Cc: Andrey Repin Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" 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