News for hackers. Stuff that matters.
Re:Two simple tricks for better shell script error handling by guns on Monday April 05, 2010 @05:37AM (#1241582)
(posted to blog comments as well)

If you decide to trap INT or TERM, it would be wise to properly kill your process with INT or TERM:

    # if you're using bash, you can use $BASHPID in place of $$
    for sig in INT TERM EXIT; do
        trap "rm -f \"\$TMPFILE\"; [[ $sig == EXIT ]] || kill -$sig $$" $sig
    done
Not propagating signals in this manner is being a bad Unix citizen. Bash would have re-raised the SIGNAL, so you should too.

For more information: http://www.cons.org/cracauer/sigint.html

Re:Two simple tricks for better shell script error handling by liraz on Monday April 05, 2010 @09:52AM (#1241886)
I haven't run into any problems (yet) obstructing signal propagation in my scripts but as you point out it's not The Correct Thing To Do. For the sake of correctness I'll be updating my error handling code. I find doing the correct thing often saves me from debugging strange edge cases.

(replied to on blog comments as well)