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

Re: [Bug] Exiting shell from function called by trap handler always produces status 0



Op 09-10-18 om 09:49 schreef Peter Stephenson:
On Mon, 2018-10-08 at 14:02 +0100, Martijn Dekker wrote:
When a trap handler exits the shell using the 'exit' command within a
function, the shell's exit status is zero even if another exit status
was given as an argument to the 'exit' command.
$ Src/zsh -c 'fn() { exit 13; }; trap "fn" EXIT'
$ echo $?
0
(expected output: 13)
diff --git a/Src/builtin.c b/Src/builtin.c
index c5b319b..b81acdb 100644
[...]

This still doesn't fix it. Output identical to above.

+  $ZTST_testdir/../Src/zsh -fc 'fn() { exit 13; }; trap fn EXIT; exit'

The extra '; exit' at the end makes it work correctly, but should not be necessary.

Thanks,

- M.




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