On Mon, 18 Aug 2025, Thomas Wolff via Cygwin wrote:

> Hi,
> a recent patch in MSYS:
> https://github.com/msys2/msys2-runtime/commit/cd4b539b367dc2a21041405cb52d3bf5dbf1a3be
> supports finer-grained control about runtime behaviour as configured via
> MSYS/Cygwin environment.
> Maybe it would be a good idea to patch cygwin upstream likewise.
>
> Test case (here in Windows German language configuration):
>
> MSYS:
>  > xcopy
> Unzulässige Parameteranzahl
> 0 Datei(en) kopiert
>  > MSYS=disable_pcon xcopy
> Unzul▒ssige Parameteranzahl
> 0 Datei(en) kopiert
>  >
>
> Cygwin:
>  > xcopy
> Unzulässige Parameteranzahl
> 0 Datei(en) kopiert
>  > CYGWIN=disable_pcon xcopy
> Unzulässige Parameteranzahl
> 0 Datei(en) kopiert
>  > CYGWIN=disable_pcon sh -c xcopy
> Unzul�ssige Parameteranzahl
> 0 Datei(en) kopiert
>  >
>
> In Cygwin, an additional shell is needed to make the $CYGWIN
> configuration effective, in MSYS now it works directly.
> Question, being curious: How does this work at all? What system call of
> the shell makes the change effective?


In Cygwin, the CYGWIN environment variable (renamed to MSYS in MSYS2) is
parsed at process start and global variables are initialized based on what
settings are in there.  That MSYS2 patch causes the environment variable
to be re-parsed as the environment is prepared for spawning a new process.
This enables settings that change how a process is launched to take effect
for *that* process launch, instead of just initializing the variables in
the child differently so that processes *it* launches will be done with
the new settings.

A potential downside that I see is that settings changes might "leak" into
the parent process that were intended to only take effect for the child.

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