Created
January 18, 2016 12:35
-
-
Save mrinalwadhwa/22d738e5d4370f5f2cf8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# redsymbol.net/articles/unofficial-bash-strict-mode/ | |
set -euo pipefail | |
IFS=$'\n\t' | |
# `set` is safer than relying on a hashbang like `#!/bin/bash -e` | |
# because that is neutralized when someone runs the script as `bash script.sh` | |
# Exit on error. Append `|| true` if we expect an error. | |
# set -o errexit | |
# hashbang0.com/2010/05/18/robust-bash-scripts-part-one | |
# set -o nounset | |
# Bash will remember & return the highest exitcode in a chain of pipes. | |
# This way you can catch the error in case `a` fails in `a | b` | |
# set -o pipefail | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment