Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Sat, 21 Aug 2004 18:38:42 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: "Buchbinder, Barry (NIH/NIAID)" cc: cygwin AT cygwin DOT com Subject: RE: environment variable name converted to upper case In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.39 On Sat, 21 Aug 2004, Buchbinder, Barry (NIH/NIAID) wrote: > To expand on what Chris wrote, this is caused by the fact that in > command.com (but not cmd.exe as supplied by XP - I don't know about earlier > versions of cmd.exe) all user-setable Windows environmental variable are > uppercase. That's not quite true. cmd.exe under XP and 2k preserves the case of variable names, but accesses to the variables are still case-insensitive. > [snip] > Now > > echo %ZZZ% > aaa > > echo %zzz% > aaa The same happens under cmd.exe. Try also "echo %zZz%". :-) > Note that in some versions of Windows, Windows itself sets a variable with a > lowercase name so that it would be impossible for the user to set it. > Windows 98se has > windir=C:\WINDOWS > I can > > set windir=xxx > and find that > windir=C:\WINDOWS > is unchanged but I now have a variable > WINDIR=xxx > But it cannot be accessed as seen by > > echo %windir% > C:\WINDOWS > > echo %WINDIR% > C:\WINDOWS This is expected, since, as I said before, variable names are case-insensitive in %..% accesses. They apparently aren't in the set command, so set will append a new entry to the end of the environment block with the lowercase name. Upon searching, however (and the environment is searched linearly, no fancy stuff like hashing) the uppercase version is found first (since it was set earlier). > My guess is that on XP, cygwin.bat runs under command.com (which is > available under all versions of Windows), not cmd.exe (provided only with > NT/2k/XP). FYI, there's a clone of cmd.exe for Win9x/ME. That won't help much, however, since even in cmd.exe variable accesses are case-insensitive. > As Chris said, the easiest way to set the variable is in the shell. True. > Under NT/2k/XP, you might get the behavior you want by changing > cygwin.bat to cygwin.cmd, or running bash directly (if the variable is > set in the global environment). Not true. The behavior of changing the case of the variable names is coming from Windows, namely the GetEnvironmentStrings() call. I just tried a small application from MSDN that just calls GetEnvironmentStrings() and prints out the result[*]. All of the variable names that come from the Windows environment were uppercased. > You'll have to experiment. For the record, under Windows 9x/Me, setting > the environmental variable in the shell is probably the only way to do > it. Not quite true. Setting the variable in the shell is *the* only way to do it, independent of the OS. HTH, Igor [*] Example 3 from > -----Original Message----- > From: Christopher Faylor [mailto:cgf-no-personal-reply-please AT cygwin DOT com] > Sent: Saturday, August 21, 2004 12:21 PM > To: cygwin AT cygwin DOT com > Subject: Re: environment variable name converted to upper case > > On Sat, Aug 21, 2004 at 09:30:53PM +0530, Koduru, Seshasai wrote: > >An environment variable name defined in windows environment with > >lowercase is converted to uppercase by cygwin environment. > > > >Because of this behavior the shell scripts are not recognizing > >$lowercase variable. Is this the regular expected behavior? > > Yes. > > >Is there any way to get the case preserved? > > Don't set the environment variable at the windows level. Set it in the > shell prior to running the program. > > If that isn't adequate, then there probably isn't any way to do what you > want. -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Happiness lies in being privileged to work hard for long hours in doing whatever you think is worth doing." -- Dr. Jubal Harshaw -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/