equal
deleted
inserted
replaced
22 |
22 |
23 |
23 |
24 HGTMP="" |
24 HGTMP="" |
25 cleanup_exit() { |
25 cleanup_exit() { |
26 rm -rf "$HGTMP" |
26 rm -rf "$HGTMP" |
27 exit $1 |
|
28 } |
27 } |
29 |
28 |
30 # Remove temporary files even if we get interrupted |
29 # Remove temporary files even if we get interrupted |
31 trap "cleanup_exit 255" TERM KILL INT QUIT ABRT |
30 trap "cleanup_exit" 0 # normal exit |
|
31 trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM |
32 |
32 |
33 HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$" |
33 HGTMP="${TMPDIR-/tmp}/hgeditor.$RANDOM.$RANDOM.$RANDOM.$$" |
34 (umask 077 && mkdir "$HGTMP") || { |
34 (umask 077 && mkdir "$HGTMP") || { |
35 echo "Could not create temporary directory! Exiting." 1>&2 |
35 echo "Could not create temporary directory! Exiting." 1>&2 |
36 exit 1 |
36 exit 1 |
49 echo -e "\nmanifest hash: $MANIFEST" >> "$HGTMP/msg" |
49 echo -e "\nmanifest hash: $MANIFEST" >> "$HGTMP/msg" |
50 fi |
50 fi |
51 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$HGTMP/msg" |
51 grep -vE '^(HG: manifest hash .*)?$' "$1" >> "$HGTMP/msg" |
52 |
52 |
53 CHECKSUM=`md5sum "$HGTMP/msg"` |
53 CHECKSUM=`md5sum "$HGTMP/msg"` |
54 $EDITOR "$HGTMP/msg" "$HGTMP/diff" || cleanup_exit $? |
54 $EDITOR "$HGTMP/msg" "$HGTMP/diff" || exit $? |
55 echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && cleanup_exit 13 |
55 echo "$CHECKSUM" | md5sum -c >/dev/null 2>&1 && exit 13 |
56 |
56 |
57 if [ "$SIGN" == "1" ]; then |
57 if [ "$SIGN" == "1" ]; then |
58 { |
58 { |
59 head -n 1 "$HGTMP/msg" |
59 head -n 1 "$HGTMP/msg" |
60 echo |
60 echo |
62 } > "$HGTMP/msg.gpg" && mv "$HGTMP/msg.gpg" "$1" |
62 } > "$HGTMP/msg.gpg" && mv "$HGTMP/msg.gpg" "$1" |
63 else |
63 else |
64 mv "$HGTMP/msg" "$1" |
64 mv "$HGTMP/msg" "$1" |
65 fi |
65 fi |
66 |
66 |
67 cleanup_exit $? |
67 exit $? |