Subject: Re: Bugs in SetEnv and UnsetEnv

From: Dominik Vogt <[email-masked]>
Date: Thu, 30 Sep 2004 20:40:04 +0200

On Thu, May 29, 2003 at 10:23:48PM +0000, Mikhael Goikhman wrote:
> I would like to get some feedback before I try to resolve these bugs.
> These are in both 2.4.x and 2.5.x.
> 
> 1) 'UnsetEnv VARNAME' does not work, the variable is not unset, instead
>    it gets an empty value "". The fix is obvious, putenv should be called
>    with "VARNAME" not "VARNAME=".

I've written a function flib_unsetenv() that uses unsetenv if the
system has it.  If not, it calls putenv("name").  If that throws
an error or does not remove the variable, it is zeroed with
putenv("name=").

> 2) It is documented that 'SetEnv VARNAME' works like 'UnsetEnv VARNAME'.
>    I don't very like such (mis)usage of SetEnv, but this is what we have.
>    Anyway, this does not work. 'SetEnv VARNAME' is just ignored, because
>    I believe the action string is already destroyed when CMD_UnsetEnv is
>    called.

  Setenv foo

is now equivalent to

  Setenv foo ""

which sets an empty string.

> 
> 3) 'SetEnv VARNAME ""' does not work as expected, it is ignored.
>    It seems that GetNextToken is bad at parsing an empty quoted string.

GetNextToken is not bad at parsing empty strings.  It's the
documented behaviour on which many callers rely.  GetNextToken
never returns an empty string.  Changing that would entail tons
of crashes.

Ciao

Dominik ^_^  ^_^

 --
Dominik Vogt, [email-masked]