From 61472a32cdb3e538f954ceb2656d0c41b4cd0b9d Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 23 May 2012 16:12:24 +0200 Subject: scripts/calcurse-upgrade: Set "-e" From the set(1p) man page: When this option is on, if a simple command fails for any of the reasons listed in Consequences of Shell Errors or returns an exit status value >0, and is not part of the compound list following a while, until, or if keyword, and is not a part of an AND or OR list, and is not a pipeline preceded by the ! reserved word, then the shell shall immediately exit. This allows us to remove all the "|| exit 1" statements we used to bail out if one command fails. Signed-off-by: Lukas Fleischer --- scripts/calcurse-upgrade | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/calcurse-upgrade b/scripts/calcurse-upgrade index 2fa7d4f..1fc481f 100644 --- a/scripts/calcurse-upgrade +++ b/scripts/calcurse-upgrade @@ -1,5 +1,7 @@ #!/bin/sh +set -e + CONFFILE=$HOME/.calcurse/conf if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \ @@ -35,8 +37,8 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \ -e 's/^output_datefmt=/format.outputdate=/' \ -e 's/^input_datefmt=/format.inputdate=/' \ -e 's/^notify-daemon_enable=/daemon.enable=/' \ - -e 's/^notify-daemon_log=/daemon.log=/' "$CONFFILE" > "$tmpfile" || exit 1 - mv "$tmpfile" "$CONFFILE" || exit 1 + -e 's/^notify-daemon_log=/daemon.log=/' "$CONFFILE" > "$tmpfile" + mv "$tmpfile" "$CONFFILE" if grep -q -e '^[^#=][^#=]*$' -e '^[^#=][^#=]*#.*$' "$CONFFILE"; then sed -e '/^general.autosave=/{N;s/\n//}' \ @@ -60,8 +62,8 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \ -e '/^format.outputdate=/{N;s/\n//}' \ -e '/^format.inputdate=/{N;s/\n//}' \ -e '/^daemon.enable=/{N;s/\n//}' \ - -e '/^daemon.log=/{N;s/\n//}' "$CONFFILE" > "$tmpfile" || exit 1 - mv "$tmpfile" "$CONFFILE" || exit 1 + -e '/^daemon.log=/{N;s/\n//}' "$CONFFILE" > "$tmpfile" + mv "$tmpfile" "$CONFFILE" fi awk ' @@ -70,7 +72,7 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \ { $2 = ($2 == "yes") ? "no" : "yes" } $1 == "general.firstdayofweek" { $2 = ($2 == "yes") ? "monday" : "sunday" } { print } - ' < "$CONFFILE" > "$tmpfile" || exit 1 - mv "$tmpfile" "$CONFFILE" || exit 1 + ' < "$CONFFILE" > "$tmpfile" + mv "$tmpfile" "$CONFFILE" fi -- cgit v1.2.3