by wyldfire · 9y ago · 0 comments
+ # safety check
+ [ "${diaspora_user_home}" != "" ] || exit 1
+ [ "${diaspora_home}" != "" ] || exit 1
... but this is key IMO: +# Abort if any unbound variables are used
+#set -u
I often use "set -euo pipefail" in my bash scripts. It does come with some caveats, though.At the top of each file with a brief comment I add:
set -o errexit
set -o nounset
set -o pipefail some_command | head
Then depending on timing, `some_command` _may_ generate all of its output and stuff it into the pipe, exiting successfully. Or `head` may get the lines it needs and close the pipe, causing `some_command` to exit with SIGPIPE. Using pipefail makes the whole pipeline fail, and then `-e` terminates the script.And it only happens sometimes.
I've some general notes on SIGPIPE mishandling at http://www.pixelbeat.org/programming/sigpipe_handling.html