Last active
July 3, 2023 02:34
-
-
Save brennanfee/f0c33c3f43e0c88635f46b599944048f to your computer and use it in GitHub Desktop.
Script Strict Modes
This file contains 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 | |
# Bash strict mode | |
([[ -n ${ZSH_EVAL_CONTEXT:-} && ${ZSH_EVAL_CONTEXT:-} =~ :file$ ]] \ | |
|| [[ -n ${BASH_VERSION:-} ]] && (return 0 2> /dev/null)) && SOURCED=true || SOURCED=false | |
if ! ${SOURCED}; then | |
set -o errexit # same as set -e | |
set -o nounset # same as set -u | |
set -o errtrace # same as set -E | |
set -o pipefail | |
set -o posix | |
#set -o xtrace # same as set -x, turn on for debugging | |
shopt -s inherit_errexit | |
shopt -s extdebug | |
IFS=$(printf '\n\t') | |
fi | |
# END Bash scrict mode |
This file contains 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 sh | |
# POSIX strict mode (may produce issues in sourced scenarios) | |
set -o errexit | |
set -o nounset | |
#set -o xtrace # same as set -x, turn on for debugging | |
IFS=$(printf '\n\t') | |
# END POSIX strict mode |
This file contains 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
SCRIPT_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
source "$(xdg-user-dir DOTFILES)/bash/script-tools.bash" | |
EXIT_CODE="0" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment