changeset 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 ca080d28d0af
children b65773f7db41
files hgeditor hgmerge
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
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 $?
--- a/hgmerge	Thu Aug 04 17:23:31 2005 +0100
+++ b/hgmerge	Thu Aug 04 17:43:05 2005 +0100
@@ -57,13 +57,13 @@
 HGTMP=""
 cleanup_exit() {
     rm -rf "$HGTMP"
-    exit $1
 }
 
 # attempt to manually merge with diff and patch
 if type diff > /dev/null 2>&1 && type patch > /dev/null 2>&1; then
     # Remove temporary files even if we get interrupted
-    trap "cleanup_exit 1" TERM KILL INT QUIT ABRT
+    trap "cleanup_exit" 0 # normal exit
+    trap "exit 1" 1 2 3 6 15 # HUP INT QUIT ABRT TERM
 
     HGTMP="${TMPDIR-/tmp}/hgmerge.$RANDOM.$RANDOM.$RANDOM.$$"
     (umask 077 && mkdir "$HGTMP") || {
@@ -73,12 +73,12 @@
 
     diff -u "$BASE" "$OTHER" > "$HGTMP/diff"
     if patch "$LOCAL" < "$HGTMP/diff"; then
-	cleanup_exit 0
+	exit 0
     else
 	# If rejects are empty after using the editor, merge was ok
-	$EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || cleanup_exit 0
+	$EDITOR "$LOCAL" "$LOCAL.rej" && test -s "$LOCAL.rej" || exit 0
     fi
-    cleanup_exit 1
+    exit 1
 fi
 
 echo "hgmerge: unable to find merge, tkdiff, kdiff3, or diff+patch!"