Set additional bash options and group together

This commit is contained in:
whiskerz007
2020-03-20 13:16:38 +01:00
parent 3563e39bdc
commit 099dd66488

View File

@@ -1,8 +1,15 @@
#!/usr/bin/env bash
set -o pipefail
# Setup script environment
set -o errexit #Exit immediately if a pipeline returns a non-zero status
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
set -o nounset #Treat unset variables as an error
set -o pipefail #Pipe will exit with last non-zero status if applicable
shopt -s expand_aliases
alias die='EXIT=$? LINE=$LINENO error_exit'
trap die ERR
trap cleanup EXIT
function error_exit() {
REASON=$1
MSG="\e[91mERROR: \e[93m$EXIT@"
@@ -19,7 +26,6 @@ function cleanup() {
popd >/dev/null
rm -rf $TMP
}
trap cleanup EXIT
TMP=`mktemp -d`
pushd $TMP >/dev/null