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

Bug with traps and exit



Found a strange issue with traps and 'exit'.

Test script:

trap 'printf $1; exit; printf $2' USR1
fn() {
        printf 1
        kill -s usr1 $$
        printf 2
}
printf 0
fn A B
printf 3

Every shell outputs 01A, except zsh, which outputs 01A2.

This means the execution of the fn() function is not interrupted. The
USR1 trap executes 'exit' and does not execute the rest of the trap
action, but instead of exiting the shell, zsh continues to execute fn()
and then exits.

Confirmed down to zsh 5.0.8 (didn't test earlier versions).

- M.



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