From 6ea0c51a0898253c89775727df4f3814c64bc877 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 28 Jul 2016 13:56:05 +0200 Subject: [PATCH] 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. --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" -- 2.30.2