--- netpbm-10.29/editor/pnmmargin- 2003-12-31 04:01:26 +0000 +++ netpbm-10.29/editor/pnmmargin 2005-10-04 16:52:44 +0000 @@ -11,11 +11,15 @@ # documentation. This software is provided "as is" without express or # implied warranty. -tempdir="${TMPDIR-/tmp}/pnmmargin.$$" -mkdir $tempdir || { echo "Could not create temporary file. Exiting."; exit 1;} -chmod 700 $tempdir - -trap 'rm -rf $tempdir' 0 1 3 15 +exit_handler() +{ + local rc=$? + trap - EXIT + rm -rf -- "$tempdir" + exit $rc +} +tempdir=`mktemp -d -t pnmmargin.XXXXXXXX` || exit 1 +trap exit_handler EXIT HUP INT QUIT PIPE TERM tmp1=$tempdir/pnmm1 tmp2=$tempdir/pnmm2