diff options
author | Luke Shumaker <lukeshu@parabola.nu> | 2013-05-27 00:40:54 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@parabola.nu> | 2017-02-16 14:42:30 -0500 |
commit | adbb2b576709b8fd15e59cfcebd672c27d50d01f (patch) | |
tree | a81e9362fd69884a65e19b5f86195fccf0608192 | |
parent | bdd7c46322a93d4a98202e574f8e65fcd379e5ef (diff) | |
download | devtools32-adbb2b576709b8fd15e59cfcebd672c27d50d01f.tar.xz |
lib/common.sh: Adjust to work properly with `set -u`.
-rw-r--r-- | lib/common.sh | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/common.sh b/lib/common.sh index dbacebf..455eb03 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,10 +1,13 @@ +#!/hint/bash +# This may be included with or without `set -euE` + # Avoid any encoding problems export LANG=C shopt -s extglob # check if messages are to be printed using color -unset ALL_OFF BOLD BLUE GREEN RED YELLOW +declare ALL_OFF= BOLD= BLUE= GREEN= RED= YELLOW= if [[ -t 2 ]]; then # prefer terminal safe colored and bold text when tput is supported if tput setaf 0 &>/dev/null; then @@ -61,14 +64,14 @@ stat_done() { _setup_workdir=false setup_workdir() { - [[ -z $WORKDIR ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX") + [[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX") _setup_workdir=true trap 'trap_abort' INT QUIT TERM HUP trap 'trap_exit' EXIT } cleanup() { - if [[ -n $WORKDIR ]] && $_setup_workdir; then + if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then rm -rf "$WORKDIR" fi exit ${1:-0} |