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
- X-seq: zsh-workers 43647
- From: Martijn Dekker <martijn@xxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [Bug] Exiting shell from function called by trap handler always produces status 0
- Date: Mon, 8 Oct 2018 14:02:23 +0100
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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