Martijn Dekker <[email protected]> wrote:

> On FreeBSD sh, when you set the export attribute on an otherwise unset 
> variable, an empty environment variable is exported, though the variable 
> continues to be considered unset within the current shell. This is the 
> only shell I know of that does this.

A shell variable has four possible states, but two of them are not 
distibguishable (state 1) and 2)) outside the iunternal shell implementation.

1)      Variable does not exist - no related node exists.

2)      Variable exists but is unset - this results in a NULL pointer
        for the value of an existing variable node.

3)      Variable is null, this results in a value that points to an empty
        string.

4)      Variable is non-null, the value points to a non-empty string.

If you call "export" or "unset", a variable needs to be created in order to be
able to store the flags (e.g. the export flag) for that variable. This creates 
a variable in state (2).

State 1) and state 2) are both seen as a variable that "does not exist" or is 
unset. This is since calling "unset" on a variable in state 1), 3) or 4) 
crerates a variable in state 2).

Since there seem to be an agreement that the FreeBSD behavior is wrong, I do 
not need to write more.

Jörg

-- 
 EMail:[email protected]                    (home) Jörg Schilling D-13353 Berlin
    [email protected] (work) Blog: http://schily.blogspot.com/
 URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'

Reply via email to