Skip to content

Instantly share code, notes, and snippets.

@harkabeeparolus
Last active July 19, 2024 14:59
Show Gist options
  • Save harkabeeparolus/b84d6ffc0c421db0c147bb9c201dacd8 to your computer and use it in GitHub Desktop.
Save harkabeeparolus/b84d6ffc0c421db0c147bb9c201dacd8 to your computer and use it in GitHub Desktop.
Standard bash script template with unofficial strict mode
#! /usr/bin/env bash
set -o errexit -o nounset -o errtrace -o pipefail
IFS=$'\n\t'
shopt -s nullglob
# shellcheck disable=SC2154
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
warn() { [ $# -ge 1 ] && printf >&2 "%s\n" "$*"; }
main() {
echo Hello World!
}
main
warn Exiting ...
exit 0
@harkabeeparolus
Copy link
Author

harkabeeparolus commented Jul 16, 2020

Sources:

Tools:

Further reading:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment