octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #53922] unsetenv does not unset environment va


From: Ian McCallion
Subject: [Octave-bug-tracker] [bug #53922] unsetenv does not unset environment variables on Windows
Date: Fri, 29 Jun 2018 04:04:09 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

Follow-up Comment #7, bug #53922 (project octave):

I agree there is unlikely to be a real-world use case for environment
variables that only differ in case. So what Windows does, which is store the
name with its case for decorative reasons but compare ignoring case, is not
unreasonable. It is just not the same as what Unix does.

Octave programs that use environment variables cannot be shielded from this
unix-windows difference because implementing the windows rule on unix would
prevent access to variables that differ only in case, and implementing the
unix rule in windows would require storing "A" and "a" independently in the
windows environment variable store which is impossible. (I am ignoring the
"solution" in which on windows Octave environment variables are disconnected
from windows environment variables)

Hence Octave can only document that there is the difference between windows
and Octave.

Of course, resolving the unix-windows difference by documentation does not
alter the fact that there is a bug in unsetenv as the following octave script
attempts to show:

% demonstration that 
(1) setenv uses windows to store environment variables 
(2) setenv passes the name in its origianl case to windows, 
(3) windows stores the name with its original case but does not allow
    different values for names that are the same apart from case

>> setenv('ZU','123');system('set ZU');
ZU=123
>> setenv('ZU','123');system('set zu');
ZU=123
>> setenv('zl','123');system('set ZL');
zl=123
>> setenv('zl','123');system('set zl');
zl=123
>> setenv('zl','123');system('set zl');

>> system('set z');
zl=123
ZU=123

% demonstration that 
% (5) getenv is case-insensitive, the supplied name and the variable name
%     can have different case 

>> setenv('ll','123');getenv('ll')
ans = 123

>> setenv('UU','123');getenv('UU')
ans = 123

>> setenv('UL','123');getenv('ul')
ans = 123

>> setenv('lu','123');getenv('LU')
ans = 123

% demonstration that 
% (6) unsetenv is case-sensitive on windows

>> setenv('xll','123');unsetenv('xll'); getenv('xll')
ans =

>> setenv('XUU','123');unsetenv('XUU'); getenv('xuu')
ans =

>> setenv('xlu','123');unsetenv('XLU'); getenv('xlu')
ans = 123

>> setenv('XUL','123');unsetenv('xul'); getenv('xul')
ans = 123


The fix is obviously complicated by the fact that Octave passes via a unix
emulation layer on its way to windows. I suspect that layer is where the fix
would ideally be applied. 

Alterntively Octave unsetenv (on windows) could be implemented  by
setetenv('name',''). Job done AFAICS.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53922>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]