From 47f934117707b29db1ffdf519a968e333be83d84 Mon Sep 17 00:00:00 2001 From: bmandal Date: Thu, 28 May 2026 16:01:06 +0200 Subject: [PATCH] scripts: fix empty-array unbound variable error on bash 3.x (macOS) On macOS, bash 3.2 treats "${ARGS[@]}" as an unbound variable when the array is empty and set -u (nounset) is active. Replace both expansions in setup-utm-ubuntu.sh with the ${ARGS[@]+"${ARGS[@]}"} idiom, which expands only when the array is non-empty and is safe under set -u on all bash versions. Co-authored-by: Cursor --- scripts/setup-utm-ubuntu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/setup-utm-ubuntu.sh b/scripts/setup-utm-ubuntu.sh index d53119e..ce248b5 100755 --- a/scripts/setup-utm-ubuntu.sh +++ b/scripts/setup-utm-ubuntu.sh @@ -89,7 +89,7 @@ fi # --------------------------------------------------------------------------- if [[ "$CLEANUP" == true ]]; then remove_ssh_config_entry - exec "${SCRIPT_DIR}/test-utm-ubuntu.sh" "${ARGS[@]}" + exec "${SCRIPT_DIR}/test-utm-ubuntu.sh" ${ARGS[@]+"${ARGS[@]}"} fi # --------------------------------------------------------------------------- @@ -100,7 +100,7 @@ trap 'rm -f "$LOGFILE"' EXIT echo "==> Setting up UTM VM '${VM_NAME}' with DKMS (no tests) ..." -"${SCRIPT_DIR}/test-utm-ubuntu.sh" --skip-tests "${ARGS[@]}" 2>&1 | tee "$LOGFILE" +"${SCRIPT_DIR}/test-utm-ubuntu.sh" --skip-tests ${ARGS[@]+"${ARGS[@]}"} 2>&1 | tee "$LOGFILE" TEST_RC=${PIPESTATUS[0]} if [[ $TEST_RC -ne 0 ]]; then