From: v.ondruch@... Date: 2021-04-30T14:45:31+00:00 Subject: [ruby-core:103674] [Ruby master Bug#16798] ENV.replace on Windows with a variable name not respecting case will clear it 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>