Skip Menu |
Report information
Id: 130776
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: nanis [at] cpan.org
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Mon, 13 Feb 2017 17:37:13 -0500
Subject: Environment variables are case insensitive on Windows
From: "A. Sinan Unur" <nanis [...] cpan.org>
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 417b
$ echo %windir% C:\WINDOWS $ echo %WINDIR% C:\WINDOWS $ c:\opt\perl6-mingw\bin\perl6 -e "say %*ENV<WINDIR>" (Any) $ c:\opt\perl6-mingw\bin\perl6 -e "say %*ENV<windir>" C:\WINDOWS $ c:\opt\perl6-mingw\bin\perl6 -v This is Rakudo version 2017.01 built on MoarVM version 2017.01 implementing Perl 6.c. Both %*ENV<WINDIR> and %*ENV<windir> (as well as, e.g., %*ENV<WinDir> etc) should return 'C:\WINDOWS'. -- Sinan
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Mon, 13 Feb 2017 14:38:03 -0800, nanis@cpan.org wrote: Show quoted text
> $ echo %windir% > C:\WINDOWS > > $ echo %WINDIR% > C:\WINDOWS > > $ c:\opt\perl6-mingw\bin\perl6 -e "say %*ENV<WINDIR>" > (Any) > > $ c:\opt\perl6-mingw\bin\perl6 -e "say %*ENV<windir>" > C:\WINDOWS > > $ c:\opt\perl6-mingw\bin\perl6 -v > This is Rakudo version 2017.01 built on MoarVM version 2017.01 > implementing Perl 6.c. > > Both %*ENV<WINDIR> and %*ENV<windir> (as well as, e.g., %*ENV<WinDir> > etc) should return 'C:\WINDOWS'. > > -- Sinan
What would be a good approach? Store them in whatever case they come in, but apply fc() when looking up keys? If I dump all the vars with `set` I see all-uppercase, mixed-case, and all-lowercase vars. Perl 5 seems to uppercase them all (when I dump %ENV with Data::Dumper). And that naturally leads to what to do with stuff like 'ß', which Perl 5 dumps out to me as `'▀' => '42',` --- I'm thinking of just sticking a subclass of Hash to %*ENV on Windows, something along the lines of $ perl6 -e 'my %h := class :: is Hash { method AT-KEY ($k) { nextwith $k.fc }; method ASSIGN-KEY ($k, $v) { nextwith $k.fc, $v } }.new; %h<Foo> = 42; dd %h; dd %h<foo>' {:foo(42)} Int <element> = 42
Date: Tue, 14 Feb 2017 11:18:07 -0500
Subject: Re: [perl #130776] Environment variables are case insensitive on Windows
To: perl6-bugs-followup [...] perl.org
From: "A. Sinan Unur" <nanis [...] cpan.org>
Download (untitled) / with headers
text/plain 592b
I am not sure what the right strategy is ... Perl 5 seems to work mainly because they use the ANSI interfaces to get environment variables ... which means you can't get the value of $ENV{iş}. I opened this issue because I am going to think about it and thought there should be something to reference. The simple solution seems to work, but I do believe case needs to be preserved. Anyway, this is a low priority issue and I am not even certain any part of the Perl 6 machinery needs to be involved. Maybe it's sufficient for client programs to case fold when looking for keys. -- Sinan
From: "A. Sinan Unur" <nanis [...] cpan.org>
Subject: Re: [perl #130776] Environment variables are case insensitive on Windows
To: perl6-bugs-followup [...] perl.org
Date: Thu, 2 Mar 2017 12:22:28 -0500
Download (untitled) / with headers
text/plain 937b
I have done some research on this issue. The "correct" behavior seems to be to match what Windows would do in cmd.exe. That would provide the users with the least surprise. Michael Kaplan's guidance[1] on file names seems to also describe how Windows handles names of environment variables: Show quoted text
> For the uppercasing operation, you can use CharUpper, CharUpperBuff, or LCMapString > with the LCMAP_UPPERCASE flag (and *without* the LCMAP_LINGUISTIC_CASING flag!). > (emphasis in the original)
To test whether the same applied to names of environment variables as well, I set the user locale to Turkish, and verified that iş was mapped to IŞ and not İŞ on a computer where the OS code page was not Turkish. The most straightforward function to use is thus CharUpperBuffW[2]. [1]: http://archives.miloush.net/michkap/archive/2005/10/17/481600.html [2]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms647475(v=vs.85).aspx


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org