Many examples for
trap ... INT TERM EXIT for cleanup tasks. But is it really necessary to list all the three sigspecs?
If a SIGNAL_SPEC is EXIT (0) ARG is executed on exit from the shell.
which I believe applies whether the script finished normally or it finished because it received
SIGTERM. An experiment also confirms my belief:
$ cat ./trap-exit #!/bin/bash trap 'echo TRAP' EXIT sleep 3 $ ./trap-exit & sleep 1; kill -INT %1  759 TRAP + Interrupt ./trap-exit $ ./trap-exit & sleep 1; kill -TERM %1  773 TRAP + Terminated ./trap-exit
Then why do so many examples list all of
INT TERM EXIT? Or did I miss something and is there any case where a sole
EXIT would miss?