3 ms·
EXIT is trapped in the same way as 0, it's something that happens when your shell exits. Ctrl+C sends the SIGINT signal but you can catch it with INT too. You w
by exdsq 6y ago
EXIT is trapped in the same way as 0, it's something that happens when your shell exits. Ctrl+C sends the SIGINT signal but you can catch it with INT too. You want to do the latter because your gracefully exiting the script, if you want to have some cleanup after that you could trap EXIT (for deleting tmp files or something).
- jwilk 6y agoWriting good SIGINT handler is a bit tricky. You should re-raise the signal, so that bash notices that the program was actually interrupted: https://www.cons.org/cracauer/sigint.html https://www.cons.org/cracauer/sigint.html (section "How to be a proper program") Most of the time, especially for short lived script, adding signal handlers is not worth the trouble.