diff hgeditor @ 831:232d0616a80a

Cleaned up trap handling: - Use numbers instead of signal names - No need to explicitly call "cleanup_exit RC" to exit with return code RC.
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 04 Aug 2005 17:43:05 +0100
parents 0902ffece4b4
children 1fe3b14c7044
line wrap: on
line diff
--- a/hgeditor	Thu Aug 04 17:23:31 2005 +0100
+++ b/hgeditor	Thu Aug 04 17:43:05 2005 +0100
@@ -24,11 +24,11 @@
 HGTMP=""
 cleanup_exit() {
     rm -rf "$HGTMP"
-    exit $1
 }
 
 # Remove temporary files even if we get interrupted
-trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
+trap "cleanup_exit" 0 # normal exit
+trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
 
 HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$"
 (umask 077 && mkdir "$HGTMP") || {
@@ -51,8 +51,8 @@
 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$HGTMP/msg"
 
 CHECKSUM=`md5sum "$HGTMP/msg"`
-$EDITOR "$HGTMP/msg" "$HGTMP/diff" || cleanup_exit $?
-echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && cleanup_exit 13
+$EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $?
+echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && exit 13
 
 if [ "$SIGN" == "1" ]; then
     {
@@ -64,4 +64,4 @@
     mv "$HGTMP/msg" "$1"
 fi
 
-cleanup_exit $?
+exit $?