2 ms·
This is unnecessary. The EXIT trap fires on any exit from the shell, not just graceful exit.
by eridius 9y ago
This is unnecessary. The EXIT trap fires on any exit from the shell, not just graceful exit.
- jwilk 9y agoThe behavior varies with shell: $ cat test_trap trap 'echo exiting' EXIT kill $$ $ bash test_trap exiting Terminated $ ksh test_trap exiting Terminated $ mksh test_trap exiting $ dash test_trap Terminated $ zsh test_trap Terminated
- eridius 9y agoThis article is specifically about Bash. I'm not surprised that `trap` behavior varies per shell, and I'd recommend reading the documentation on it.