Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 108:43:43 |
Calls: | 290 |
Files: | 905 |
Messages: | 76,699 |
Note: This thread is entirely about bash. No other shells or "POSIX" are relevant here. But comparisons between various versions of bash may be relevant, since I think the behavior may have changed over the versions.
That said, suppose I have something like:
trap 'date > /tmp/somefile' EXIT
# Rest of script
Now, if during "Rest of script", say I hit ^C. Or ^\. Or, say I send a signal via "kill" from another terminal. Does my exit trap get executed?
I've had varying results. I am pretty sure that at one point, the answer
was "no", but recently, I've noticed that when I exit via ^C, the EXIT trap does execute. I'm curious what the "official" answer is.