diff --git a/install.sh b/install.sh index 2d7c12e..912340c 100644 --- a/install.sh +++ b/install.sh @@ -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