Re: environment variable name converted to upper case

2004-08-24 Thread Shankar Unni
Larry Hall wrote:
I'm not sure what you mean by 'Posix shells'.  Shells that come with the
Cygwin environment don't expect uppercase.  Windows (and DOS) do, really.
OK, I was a little imprecise.
What I was trying to say was that NT *shells* preserves case in 
environment variables, but is case-insensitive in lookup. Which is why 
it allows variables like "Path" or "PATH" interchangeably. You can set 
"foo", but look up "%FoO%" or "%fOo", and it'll find that "foo" and 
return it. But just "set" prints out "foo=...", not "FOO=...".

"Posix shells" (OK, another bad term - I mean shells originally written 
to run on Unix-y or Posix-y systems - i.e. sh, bash, ksh, csh, etc., but 
not CMD, COMMAND.COM, 4NT, or others), on the other hand, are completely 
case-preserving and case-sensitive.

And in order to be able to see PATH in the environment in cygwin shells 
when the system had set Path, cygwin uppercases all environment vars 
when starting a cygwin process. What I was saying was, how about 
uppercasing just "Path/PATH"? We can leave the case of the others alone, 
as they are in the system environment.

OK, sure, there's minor complexity in saying
  if (stricmp(var, "path") == 0)
uppercase(var)
instead of just
  uppercase(var)
but it reduces the needless element of surprise at the unnecessary 
munging of the environment.

Anyway, not a big point; just a suggestion, and it looks like it's been 
shot down. That's ok..

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


Re: environment variable name converted to upper case

2004-08-23 Thread Christopher Faylor
On Mon, Aug 23, 2004 at 02:13:56PM -0700, Shankar Unni wrote:
>Christopher Faylor wrote:
>>To repeat, translating environment variables to uppercase is something
>>that *cygwin* does.  Check out environ.cc for more information.
>
>Could the uppercasing be limited to certain environment variables?
>Particularly, only PATH, since that's common to both NT and Posix
>shells, but that NT allows in any case while Posix shells expect in
>uppercase?

I don't see any reason to do so.  This is trivial to work around and
cygwin's current behavior has not changed for many years.

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



Re: environment variable name converted to upper case

2004-08-23 Thread Larry Hall
At 05:13 PM 8/23/2004, you wrote:
>Christopher Faylor wrote:
>
>>To repeat, translating environment variables to uppercase is something
>>that *cygwin* does.  Check out environ.cc for more information.
>
>Could the uppercasing be limited to certain environment variables? Particularly, only 
>PATH, since that's common to both NT and Posix shells, but that NT allows in any case 
>while Posix shells expect in uppercase?


I'm not sure what you mean by 'Posix shells'.  Shells that come with the
Cygwin environment don't expect uppercase.  Windows (and DOS) do, really.
Is it possible to change the behavior in Cygwin to selectively uppercase
environment variables inherited from Windows?  Sure.  I doubt it will happen
unless there's a really good reason to do so, since it introduces complexity.
But, if you decide to make the change yourself for your own needs, feel free
to submit the patch to cygwin-patches.  If I'm wrong and/or if you can make 
a good case for it, I'm sure it will be accepted.



--
Larry Hall  http://www.rfk.com
RFK Partners, Inc.  (508) 893-9779 - RFK Office
838 Washington Street   (508) 893-9889 - FAX
Holliston, MA 01746 


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



Re: environment variable name converted to upper case

2004-08-23 Thread Shankar Unni
Christopher Faylor wrote:
To repeat, translating environment variables to uppercase is something
that *cygwin* does.  Check out environ.cc for more information.
Could the uppercasing be limited to certain environment variables? 
Particularly, only PATH, since that's common to both NT and Posix 
shells, but that NT allows in any case while Posix shells expect in 
uppercase?

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


Re: environment variable name converted to upper case

2004-08-22 Thread Igor Pechtchanski
On Sun, 22 Aug 2004, Christopher Faylor wrote:

> On Sat, Aug 21, 2004 at 01:06:50PM -0400, 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.
> 
> No.  Cygwin goes out of its way to change environment variables to upper
> case.  Environment variables in windows, on NT+ at least, can be mixed
> case.  Unfortunately, sometimes you find things like "Path" instead of
> "PATH" so Cygwin needs to rectify that.
> 
> To repeat, translating environment variables to uppercase is something
> that *cygwin* does.  Check out environ.cc for more information.
> 
> cgf

Umm, yes, I just found that call to ucenv().  I can't believe I missed it 
earlier -- and I did look through environ.cc before answering.  Apologies 
for confusing the issue.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,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/



Re: environment variable name converted to upper case

2004-08-22 Thread Christopher Faylor
On Sat, Aug 21, 2004 at 01:06:50PM -0400, 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.

No.  Cygwin goes out of its way to change environment variables to upper
case.  Environment variables in windows, on NT+ at least, can be mixed
case.  Unfortunately, sometimes you find things like "Path" instead of
"PATH" so Cygwin needs to rectify that.

To repeat, translating environment variables to uppercase is something
that *cygwin* does.  Check out environ.cc for more information.

cgf

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



RE: environment variable name converted to upper case

2004-08-21 Thread Igor Pechtchanski
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 
<http://msdn.microsoft.com/library/en-us/dllproc/base/changing_environment_variables.asp>

> -Original Message-
> From: Christopher Faylor [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, August 21, 2004 12:21 PM
> To: [EMAIL PROTECTED]
> 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/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,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/



RE: environment variable name converted to upper case

2004-08-21 Thread Buchbinder, Barry (NIH/NIAID)
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.  Try this in command.com:  
> set
You will see all the environmental variable are uppercase.  Now
> set zzz=aaa
> set
will show that zzz is listed as
ZZZ=aaa
Now
> echo %ZZZ%
aaa
> echo %zzz%
aaa
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
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).

As Chris said, the easiest way to set the variable is in the shell.  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).  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.

-Original Message-
From: Christopher Faylor [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 21, 2004 12:21 PM
To: [EMAIL PROTECTED]
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.

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

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



Re: environment variable name converted to upper case

2004-08-21 Thread Christopher Faylor
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.

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