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

Re: Value of $? after unsetting non-existent shell variable

"Kevin B. McCarty" <kmccarty@Princeton.EDU> writes:

> So, who's right and who's wrong here?  And if either return value is
> acceptable, could it at least be made consistent between different shells?

SUSv3 says:

        Unsetting a variable or function that was not previously
        set shall not be considered an error and does not cause
        the shell to abort.



                All name operands were successfully unset.
                At least one name could not be unset.

So it seems that "unset nosuchvariable" should have a return
status of 0.
"To the engineer, the world is a toy box full of sub-optimized and
 feature-poor toys."
--Scott Adams

Reply to: