> Date: Fri, 09 Jan 2009 23:58:02 +0100
> From: Roland Mainz <roland.mainz at nrubsig.org>
> > > > *Change Request ID*: 6791838
> > > >
> > > > *Synopsis*: *ksh93* unset of a variable which is not set should return 0
> > > >
...
> > > > === *Description*
> > ============================================================
> > > > In ksh93, the special builtin "unset" will exit 1 when its argument is a
> > > > variable which is not set, but it should exit 0, according to the POSIX
> > standards.
> > >
> > > Erm... I interpret the standard a bit different in this case:
> > > http://www.opengroup.org/onlinepubs/000095399/utilities/unset.html says:
> > > -- snip --
> > > EXIT STATUS
> > >
> > >      0
> > >         All name operands were successfully unset.
> > >     >0
> > >         At least one name could not be unset.
> > > -- snip --
> > >
> > > Both ksh88, ksh93 and /usr/xpg4/bin/sh in Solaris behave like this:
> > > -- snip --
> > > $ /usr/xpg4/bin/sh -c 'unset kjashdjkashd || print "unset returned
> > > non-zero exit code"'
> > > unset returned non-zero exit code
> > > $ ksh -c 'unset kjashdjkashd || print "unset returned non-zero exit
> > > code"'
> > > unset returned non-zero exit code
> > > $ ksh93 -c 'unset kjashdjkashd || print "unset returned non-zero exit
> > > code"'
> > > unset returned non-zero exit code
> > > -- snip --
> > >
> > > Don: Is there any clarification request which defined the behaviour of
> > > "unset" more precisely ?
> > 
> > I did confirm this interpretation with Don Cragun, and he agrees.
> > ksh93 (and the Solaris standard shell /usr/xpg4/bin/sh) would need to 
> > return 
0
> > in the case of unsetting a variable which is not set, to
> > conform with the standard.
> > 
> > I guess you could also interpret the
> > > 0 exit value for "at least one name could not be unset"
> > to not be true in this case.  The name was unset already, so the result
> > is still that the name is unset.  Therefore, unset was successful.
> 
> Ok...
> ... right now ksh93 prints the following output for the following two
> testcases:
> -- snip --
> $ ksh93 -c 'unset kjashdjkashd ; print $? ; unset kjashdjkashd ; print
> $?'                                               
> 1
> 1
> $ ksh93 -c 'kjashdjkashd="abc" ; unset kjashdjkashd ; print $? ; unset
> kjashdjkashd ; print $?'                          
> 0
> 0
> -- snip --
> 
> What is the expected output in both cases ? Does this change mean the
> shell will have to track variable names even if they were "unset" (until
> now I always interpreted $ unset varname # as a variable/shell
> equivalent to "rm", e.g. once the variable is "unset" it is really gone
> and no traces are left) or that "unset" just returns "0" in all cases
> above ?
> 

In both cases, unset should return 0.  If it doesn't do it now, I don't
think that any tracking is needed for unset variables.

        April


Reply via email to