From 231c9cfb0b64c3c566d89f0cd1ae5b0b124a9f25 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Tue, 8 Aug 2023 07:51:43 -0700 Subject: *: fix trap calls to ensure call on regular exit and errors Signed-off-by: Robin H. Johnson --- create-squashfs-snapshot | 4 ++-- sign-sync-binpackages.sh | 4 ++-- verify-digests.sh | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/create-squashfs-snapshot b/create-squashfs-snapshot index 1579877..4fc35ff 100755 --- a/create-squashfs-snapshot +++ b/create-squashfs-snapshot @@ -69,8 +69,8 @@ reponame=$(<"${repodir}"/profiles/repo_name) [[ ${reponame} ]] tempdir=$(mktemp -d) - -trap 'rm -r "${tempdir}"' EXIT +[[ -z $tempdir ]] && echo "Failed to create tempdir" 1>&2 && exit 97 +trap 'rm -rf "${tempdir}"' SIGINT SIGTERM EXIT # Build exclusion list EXCLUSION_LIST="$(mktemp -p "${tempdir}" squashfs-exclude.XXXXXXXXXX)" diff --git a/sign-sync-binpackages.sh b/sign-sync-binpackages.sh index 862cea9..4c85365 100755 --- a/sign-sync-binpackages.sh +++ b/sign-sync-binpackages.sh @@ -53,9 +53,9 @@ if [[ -f ${LOCKFILE} ]] ; then echo sign-sync-binpackages.sh lockfile ${LOCKFILE} exists, aborting exit 112 fi -touch ${LOCKFILE} || exit 110 +touch "${LOCKFILE}" || exit 110 # ensure the lock is cleaned on exit -trap "rm -f ${LOCKFILE}" SIGINT SIGTERM +trap 'rm -f "${LOCKFILE}"' SIGINT SIGTERM EXIT # make sure we have an updated gpg-agent gpgconf --kill all diff --git a/verify-digests.sh b/verify-digests.sh index bf39a87..bd0cfa8 100755 --- a/verify-digests.sh +++ b/verify-digests.sh @@ -100,7 +100,7 @@ T=$(date -u +%Y%m%dT%H%M%SZ) tmp1=$(mktemp --tmpdir) tmp2=$(mktemp --tmpdir) failures=$(mktemp --tmpdir gentoo-failures.$T.XXXXXXXXXX) -trap "rm -f $tmp1 $tmp2" SIGINT SIGTERM +trap 'rm -f "${tmp1}"" "${tmp2}"' SIGINT SIGTERM EXIT # Now check them failed_digests=() -- cgit v1.2.3-65-gdbad