bugGNU Octave - Bugs: bug #53922, unsetenv does not unset...

 
 

bug #53922: unsetenv does not unset environment variables on Windows

Submitted by:  Ian McCallion <ianmcc>
Submitted on:  Wed 16 May 2018 08:54:25 AM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  4.4.0 Operating System:  Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 17 May 2018 11:07:14 PM UTC, comment #5:

I can see the appeal of supporting case-sensitive environment variables, but it would break some existing applications (including mine by the way!)

Are bash environment variables connected to windows environment variables at all?

Ian McCallion <ianmcc>
Thu 17 May 2018 06:00:47 PM UTC, comment #4:

Octave uses Gnulib for the 'putenv' and 'unsetenv' functions. The 'putenv' function also allows unsetting an environment variable, but Octave does not currently use that option. And Gnulib also offers a 'setenv' function that Octave does not use, maybe it should use that instead of 'putenv'.

I think someone who can test all of the various combinations of these Gnulib functions in Windows with differently cased environment variables should do so, and Octave will use whatever the results indicate to use. It's not clear to me which functions are meant to be used with which other functions.

IMHO, it would be best if Octave supported case sensitive environment variables even on Windows, just as bash running on Windows appears to.

Mike Miller <mtmiller>
Project Administrator
Thu 17 May 2018 10:39:23 AM UTC, comment #3:

unsetenv does work sometimes, as this octave command sequence shows:

However weirdly, in spite of all the environment getting and setting operations being case-insensitive, windows still saves the environment variable with its name in its original case as its value is changed, as this windows commandline sequence shows:

Hence I reckon unsetenv merely needs to do a case-insensitive comparison (on Windows only of course) when searching for the environment variable to unset.

Ian McCallion <ianmcc>
Wed 16 May 2018 08:10:37 PM UTC, comment #2:

Ok, now I see that Octave uses Gnulib's 'putenv' function, which calls the Winows function SetEnvironmentVariable, which is probably where the case insensitivity comes in. But Gnulib's 'unsetenv' function iterates over the 'environ' global variable directly, and doesn't seem to correspond to anything set with SetEnvironmentVariable.

It looks to me like 'unsetenv' simply does not work at all with 'putenv', even ignoring case sensitivity. The 'unsetenv' function simply does not work on Windows right now.

Mike Miller <mtmiller>
Project Administrator
Wed 16 May 2018 06:19:14 PM UTC, comment #1:

Yes, environment variable names can include both uppercase and lowercase ASCII letters, and Octave's getenv, setenv, putenv, and unsetenv functions all support that.

I think the bug is that the environment variable should not be cleared in both cases.

The Gnulib setenv and unsetenv replacement functions should use case-sensitive string matching to add, replace, and remove environment variables. If that's not true, then that's a bug.

Mike Miller <mtmiller>
Project Administrator
Wed 16 May 2018 08:54:25 AM UTC, original submission:

Environment variable names on Windows are case insensitive (I don't know about on unix). The setenv and getenv functions implement this correctly but unsetenv does not.

Invoking the function below with no parameters causes it to use setenv to clear the environment variable, which is as it should be. Invoking it supplying the parameter "unset" causes it to use unset and the variables are not unset.

Ian McCallion <ianmcc>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by ianmcc (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-16 mtmiller StatusNeed Info => Confirmed
        Summaryunset case sensitivity => unsetenv does not unset environment variables on Windows
    2018-05-16 mtmiller StatusNone => Need Info
        Operating SystemMac OS => Microsoft Windows

    Back to the top


    Powered by Savane 3.3