Re: [RFA/mingw32] environment variables are case-insensitive on win32

Corinna Vinschen
2012-12-11T14:41:17Z

On Dec 11 14:25, Pedro Alves wrote:
> On 12/10/2012 03:57 PM, Corinna Vinschen wrote:
> > Probably an old Cygwin version. Older versions of Cygwin did not
> > honor the case of env vars, but rather converted them all to uppercase,
> > but this is pre-2008!
>
> I'm confused by this. It looks like even with such old Cygwin, Cygwin
> programs treated environment variables as case-sensitive, otherwise
> the
>
> $ env | grep TEST_GDB
> TEST_GDB_V=1
> TEST_GDB_v=2
>
> in Jerome's test would have only shown one TEST_GDB_V, right?

I phrased my reply too simple, sorry! What happens is this:

Internally, Cygwin doesn't use the Windows environment, but rather a
POSIX equivalent. When a Cygwin process forks or executes another
Cygwin process, the environment is given to the child process in the
POSIXified layout, not using the CreateProcess environment pointer.

However, when a Cygwin process gets started by a *non*-Cygwin process,
this internal mechanism can't work, and the POSIX environment is created
from the Windows environment. Up until 2008, all environment variables
in the Windows env were converted to uppercase when creating the POSIX
env. In 2008 we changed that mechanism to uppercase only a certain set
of env vars, and that's done up to today for compatibility reasons. The
list of still uppercased vars is this:

ALLUSERSPROFILE
COMMONPROGRAMFILES
COMPUTERNAME
COMSPEC
HOME
HOMEDRIVE
HOMEPATH
NUMBER_OF_PROCESSORS
OS
PATH
PATHEXT
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
PROGRAMFILES
SYSTEMDRIVE
SYSTEMROOT
TEMP
TERM
TMP
TMPDIR
WINDIR

Hope that clarifies the situation.

Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat