ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: v.ondruch@tiscali.cz
To: ruby-core@ruby-lang.org
Subject: [ruby-core:103674] [Ruby master Bug#16798] ENV.replace on Windows with a variable name not respecting case will clear it
Date: Fri, 30 Apr 2021 14:45:31 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-91769.20210430144531.7174@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16798.20200417111943.7174@ruby-lang.org

Issue #16798 has been updated by vo.x (Vit Ondruch).


The backport breaks on RHEL7:

~~~
hash.c: In function 'keylist_delete':
hash.c:5661:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (long i=0; i<RARRAY_LEN(keys); i++) {
     ^
hash.c:5661:5: note: use option -std=c99 or -std=gnu99 to compile your code
~~~

Interestingly, I have not met this issue in Ruby 2.7. Are there implicitly the -std=c99 or -std=gnu99 options?

----------------------------------------
Bug #16798: ENV.replace on Windows with a variable name not respecting case will clear it
https://bugs.ruby-lang.org/issues/16798#change-91769

* Author: deivid (David Rodríguez)
* Status: Closed
* Priority: Normal
* Backport: 2.5: REQUIRED, 2.6: DONE, 2.7: DONE
----------------------------------------
On Windows, environment variable names are case insensitive:

```
PS C:\Users\deivi> ruby -e "puts ENV['Path']; ENV['PATH'] = 'foo'; puts ENV['Path']"                                                                                                                                                     C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Ruby26-x64\bin;C:\Ruby25-x64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Ruby27-x64\bin;C:\Ruby25-x64\bin
foo

PS C:\Users\deivi> ruby -e "puts ENV['Path']; ENV.update('PATH' => 'foo'); puts ENV['Path']"                                                                                                                                             C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Ruby26-x64\bin;C:\Ruby25-x64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Ruby27-x64\bin;C:\Ruby25-x64\bin
foo
```

However, with `ENV.replace`, if you don't use the "canonical casing" (as given by `ENV.keys`, for example), the environment variable will be cleared.

```
PS C:\Users\deivi> ruby -e "puts ENV['Path']; ENV.replace('PATH' => 'foo'); puts ENV['Path']"                                                                                                                                                 C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Ruby26-x64\bin;C:\Ruby25-x64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Ruby27-x64\bin;C:\Ruby25-x64\bin


```

This is unexpected to me.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

      parent reply	other threads:[~2021-04-30 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-17 11:19 [ruby-core:97941] [Ruby master Bug#16798] ENV.replace on Windows with a variable name not respecting case will clear it deivid.rodriguez
2020-04-18 14:29 ` [ruby-core:97950] " deivid.rodriguez
2020-07-25  3:00 ` [ruby-core:99322] " nagachika00
2021-04-04 22:49 ` [ruby-core:103215] " usa
2021-04-30 14:45 ` v.ondruch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-91769.20210430144531.7174@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).