Skip to content

Instantly share code, notes, and snippets.

@zored
Created August 23, 2021 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zored/bdf010ec180c30c516c4586d8e131349 to your computer and use it in GitHub Desktop.
Save zored/bdf010ec180c30c516c4586d8e131349 to your computer and use it in GitHub Desktop.
Safe bash
#!/usr/bin/env bash
set -ETexuo pipefail
shopt -s inherit_errexit
# -e - stop on error.
# -E - traps will work with -e.
# -x - debug output each command.
# -u - error on unexpected variables.
# -o pipefail - handle errors of '|'.
# -s inherit_errexit - fail in subshell failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment