Skip to content

Instantly share code, notes, and snippets.

@mrinalwadhwa
Created January 18, 2016 12:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrinalwadhwa/22d738e5d4370f5f2cf8 to your computer and use it in GitHub Desktop.
Save mrinalwadhwa/22d738e5d4370f5f2cf8 to your computer and use it in GitHub Desktop.
#!/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