Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug: $? after empty command



Peter Stephenson <pws <at> csr.com> writes:

> > POSIX requires that the execution of an empty command change $? to 0, as
> > shown here with bash:
> > 
> > $ zsh -c 'foo=; false; $foo; echo $?'
> > 1
> 
> I'm not aware that that's deliberate shell behaviour, and indeed I
> wouldn't have expected it.  It *is* deliberate behaviour that the status is
> not reset simply by hitting return at the interactive prompt, but that's
> actually a different issue, not affected by the following.

Good point about making the behavior dependent on a non-empty command line, and
that the exit status of command substitution is still important.  I don't see
your patch in CVS yet, so I haven't played with it.  But just from inspection,
it looks like it does not cover these related issues, which are both required by
POSIX to output 0:

$ zsh -c 'false; . /dev/null; echo $?'
1
$ zsh -c 'false; ``; echo $?'
1

-- 
Eric Blake




Messages sorted by: Reverse Date, Date, Thread, Author