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 <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2012-05-23 16:12:24 +02:00
parent 9719de8ea3
commit 61472a32cd

View File

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
set -e
CONFFILE=$HOME/.calcurse/conf CONFFILE=$HOME/.calcurse/conf
if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \ 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/^output_datefmt=/format.outputdate=/' \
-e 's/^input_datefmt=/format.inputdate=/' \ -e 's/^input_datefmt=/format.inputdate=/' \
-e 's/^notify-daemon_enable=/daemon.enable=/' \ -e 's/^notify-daemon_enable=/daemon.enable=/' \
-e 's/^notify-daemon_log=/daemon.log=/' "$CONFFILE" > "$tmpfile" || exit 1 -e 's/^notify-daemon_log=/daemon.log=/' "$CONFFILE" > "$tmpfile"
mv "$tmpfile" "$CONFFILE" || exit 1 mv "$tmpfile" "$CONFFILE"
if grep -q -e '^[^#=][^#=]*$' -e '^[^#=][^#=]*#.*$' "$CONFFILE"; then if grep -q -e '^[^#=][^#=]*$' -e '^[^#=][^#=]*#.*$' "$CONFFILE"; then
sed -e '/^general.autosave=/{N;s/\n//}' \ 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.outputdate=/{N;s/\n//}' \
-e '/^format.inputdate=/{N;s/\n//}' \ -e '/^format.inputdate=/{N;s/\n//}' \
-e '/^daemon.enable=/{N;s/\n//}' \ -e '/^daemon.enable=/{N;s/\n//}' \
-e '/^daemon.log=/{N;s/\n//}' "$CONFFILE" > "$tmpfile" || exit 1 -e '/^daemon.log=/{N;s/\n//}' "$CONFFILE" > "$tmpfile"
mv "$tmpfile" "$CONFFILE" || exit 1 mv "$tmpfile" "$CONFFILE"
fi fi
awk ' awk '
@ -70,7 +72,7 @@ if grep -q -e '^auto_save=' -e '^auto_gc=' -e '^periodic_save=' \
{ $2 = ($2 == "yes") ? "no" : "yes" } { $2 = ($2 == "yes") ? "no" : "yes" }
$1 == "general.firstdayofweek" { $2 = ($2 == "yes") ? "monday" : "sunday" } $1 == "general.firstdayofweek" { $2 = ($2 == "yes") ? "monday" : "sunday" }
{ print } { print }
' < "$CONFFILE" > "$tmpfile" || exit 1 ' < "$CONFFILE" > "$tmpfile"
mv "$tmpfile" "$CONFFILE" || exit 1 mv "$tmpfile" "$CONFFILE"
fi fi