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

Pedro Alves
2012-12-11T14:25:54Z

On 12/10/2012 03:57 PM, Corinna Vinschen wrote:
> On Dec 10 16:42, Jerome Guitton wrote:
>> Corinna Vinschen (vinschen@redhat.com):
>>
>>> Cygwin is not Windows. Cygwin is a UNIX-like system like Linux,
>>> Solaris, OpenBSD, etc. The question you should ask is this: Would
>>> you like to match environment variable names case-insensitive on Linux,
>>> Solaris, OpenBSD? If the answer is "no", the answer for Cygwin is "no",
>>> too.
>>
>> Something may be broken in Cygwin's GDB, or maybe my version of Cygwin
>> is too old, because environment variables that have the same names are
>> identified in the inferior:
>>
>> guitton@kerel ~
>> $ export TEST_GDB_V=1
>> guitton@kerel ~
>> $ export TEST_GDB_v=2
>>
>> guitton@kerel ~
>> $ env | grep TEST_GDB
>> TEST_GDB_V=1
>> TEST_GDB_v=2
>>
>> guitton@kerel ~
>> $ /bin/gdb ./gdb/testsuite/gdb.base/testenv.exe
>> [...]
>> (gdb) r
>> Starting program: /home/guitton/GIT/GDB/builds/obj.gdb-fsf.cygwin/gdb/testsuite/gdb.base/testenv.exe
>> [New thread 12692.0x16ac]
>> [New thread 12692.0x22b0]
>> TEST_GDB_V=2
>> Program found 1 variables starting with TEST_GDB
>
> 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?

Sounds like in this old Cygwin, the env vars are only coalesced when
going through CreateProcess?

And then, if that's true, a run time test in GDB like in the present
patch, doesn't actually detect this, because GDB itself is a Cygwin
program and will behave like those export + env calls?

Oh, I think that's what Jerome is saying in

http://sourceware.org/ml/gdb-patches/2012-12/msg00134.html

?

In that case, this run-time test is looking like not helping
at all in practice. The patch still has #ifdefs for _WIN32, so
it doesn't help with portability either.

Furthermore, I see from

http://cygwin.com/cygwin-ug-net/using-cygwinenv.html

That CYGWINN=upcaseenv is more complicated than just case- or not
case-sensitivity. Even without that set, Cygwin always uppercases
a set of environment variables, so it looks like a proper Cygwin
change would contemplate all of that somehow.

So all in all, I think we should just ignore Cygwin for now (leave it
case-sensitive like today), forget the run-time test in GDB, and go
back to focusing on Windows/mingw alone.

--
Pedro Alves