Last active
October 27, 2022 20:30
-
-
Save crizCraig/f42bc250754bed764ada5f95d101dbea to your computer and use it in GitHub Desktop.
bash boilerplate
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 | |
set -e # Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs) | |
set -u # Attempt to use undefined variable outputs error message, and forces an exit | |
set -x # Similar to verbose mode (-v), but expands commands | |
set -o pipefail # Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value. | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
# end boilerplate from: https://gist.github.com/crizCraig/f42bc250754bed764ada5f95d101dbea |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From https://sharats.me/posts/shell-script-best-practices/