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

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



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)

I was able to reproduce this in zsh 5.4.1 and up, and not in 5.3.1 and earlier. Every other shell also exits with status 13.

Looping through git commits starting from zsh-5.3.1, I found the commit that introduced this: d7110d8 (41012: Fix premature exit from nested function in EXIT trap).

Thanks,

- M.



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