From: Andre Noll Date: Thu, 28 Jul 2016 11:56:05 +0000 (+0200) Subject: gsu_make_tempfile(): Avoid reading an unbound variable. X-Git-Url: http://git.tuebingen.mpg.de/?p=gsu.git;a=commitdiff_plain;h=6ea0c51a0898253c89775727df4f3814c64bc877 gsu_make_tempfile(): Avoid reading an unbound variable. If a gsu script (a) enables the -u option to treat unset variables as an error for parameter expansion, (b) does not set TMPDIR, (c) calls gsu_make_tempfile(), gsu_make_tempfile() fails with an "TMPDIR: unbound variable" error. The code already contains a fallback for this case, so we can use the :- construct to avoid the error and fall back to /tmp if TMPDIR is unset or NULL. --- diff --git a/common b/common index 4e1d115..ec7b8e2 100644 --- a/common +++ b/common @@ -107,7 +107,7 @@ gsu_make_tempfile() if [[ "${template:0:1}" != '/' ]]; then # relative path if (($# > 1)); then dir="$2" - elif [[ -n "$TMPDIR" ]]; then + elif [[ -n "${TMPDIR:-}" ]]; then dir="$TMPDIR" else dir="/tmp"