“Exit traps” can make your Bash scripts more robust and reliable (2013)
I used an exit trap to kill an SSH agent that I am running, and I noticed that dash did not kill if the script was interrupted, but only if it ran to successful completion.<p>I asked on the mailing list if this was expected behavior, and it turns out that POSIX only requires EXIT to run on a clean shutdown; to catch interruptions, add more signals.<p><pre><code>  trap 'eval $(ssh-agent -k)' EXIT INT ABRT KILL TERM</code></pre>