--- netpbm-10.29/editor/ppmquantall- 2005-03-16 23:44:03 +0000 +++ netpbm-10.29/editor/ppmquantall 2005-10-04 16:50:28 +0000 @@ -63,11 +63,15 @@ for i in ${files[@]}; do heights=(${heights[*]} `grep -v '^#' $i | sed '1d; s/.* //; 2q'`) done -tempdir="${TMPDIR-/tmp}/ppmquantall.$$" -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 ppmquantall.XXXXXXXX` || exit 1 +trap exit_handler EXIT HUP INT QUIT PIPE TERM all=$tempdir/pqa.all.$$