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

Re: zsh exit status



Phil Pennock wrote:
>When zsh exits, it returns the exit code of the last process to exit.
>Which is correct.  However, when the last process exited on a signal, it
>returns the full status back.

What actually happens is that the process exiting on a signal (e.g.,
SIGINT) is immediately converted into a high normal exit status (e.g.,
130), at the point that the status is retrieved using wait().  If the
value in lastval ($?) is >128, it is impossible to determine from it
whether the last command exited normally or on a signal.  When zsh
subsequently exits, it exits *normally* with the high exit status.
If the invoking shell is another Bourne-like shell, it similarly won't
be able to tell whether zsh exited on a signal or not; with Perl you'd
be able to tell the difference.

>I've checked, and both bash and pdksh also pass this unchanged.  Is
>this behaviour mandated by any standards?

POSIX.2 isn't 100% clear about it, but it looks like the only reasonable
interpretation to me.

-zefram



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