From f118441bbfa71f7e1abed6aa1a41209d266ccac2 Mon Sep 17 00:00:00 2001 From: Nikolai Kolodziej Date: Tue, 30 Jun 2026 15:41:54 +0200 Subject: [PATCH] fix(install): keep tmp global so the cleanup trap works under set -u The EXIT trap (rm -rf "$tmp") runs in global scope, but tmp was declared local to main(), so under `set -u` a successful install ended with "tmp: unbound variable" and exit 1. The binary installed fine, but the script reported failure and left the temp dir behind. Make tmp a global and guard the trap with ${tmp:-}. Verified end-to-end against the v3.0.0 release in a debian:12 container: download, checksum, install, cleanup, and `pzmod --version` all exit 0. This also fixes the release workflow's test-install jobs. --- install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 72dbc93..4ea3be8 100755 --- a/install.sh +++ b/install.sh @@ -56,7 +56,9 @@ sha256_of() { } main() { - local target os arch tag asset base tmp sudo expected actual + # tmp is intentionally NOT local: the EXIT trap below runs in global scope and + # must still see it (otherwise `set -u` trips on cleanup after a successful run). + local target os arch tag asset base sudo expected actual target="${1:-$DEFAULT_TARGET}" os="$(detect_os)" arch="$(detect_arch)" @@ -67,7 +69,7 @@ main() { info "Installing pzmod ${tag} (${os}/${arch}) to ${target}" tmp="$(mktemp -d)" - trap 'rm -rf "$tmp"' EXIT + trap 'rm -rf "${tmp:-}"' EXIT curl -fSL --proto '=https' --tlsv1.2 -o "$tmp/pzmod" "${base}/${asset}" \ || err "no prebuilt binary for ${asset} in ${tag} (see ${base})"