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

BUG?: TRAPEXIT is not executed on interruption when TRAPINT is not defined



Hi zsh contributors,

Not sure if I'm understanding this correctly, but from docs it sounds
like (top-level) TRAPEXIT should execute on any means of script
termination if possible (e.g. other than SIGKILL). Presumably, that
should include terminal interrupt.

But the following script shows that TRAPEXIT is run on graceful exit,
but does not run on interrupt until TRAPINT is also defined:

===========
#!/usr/bin/zsh
TRAPEXIT() { echo 'EXIT' }
# When uncommented, TRAPEXIT will run on SIGINT
#TRAPINT() {}
sleep 2
===========

Sample execution:

$ ./test.sh
EXIT
$ ./test.sh
^C
$ sed -e 's/#TRAPINT/TRAPINT/' -i test.sh
$ ./test.sh
^CEXIT
$ zsh --version
zsh 5.9.2 (x86_64-pc-linux-gnu)
$




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