aboutsummaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-02-23 06:06:55 -0600
committerCraig Jennings <c@cjennings.net>2026-02-23 06:06:55 -0600
commit2ef27b6a5d190c4d38eb4d13a039e10c006d7c7b (patch)
tree00cc8eccd698785d53fe4541b334f3aa71651d5b /build.sh
parent1268a283526ca4b1d11d391ede944f055b4abafd (diff)
downloadarchangel-2ef27b6a5d190c4d38eb4d13a039e10c006d7c7b.tar.gz
archangel-2ef27b6a5d190c4d38eb4d13a039e10c006d7c7b.zip
chore: add set -euo pipefail to scripts for safety
Enable undefined variable checking (set -u) and pipefail across standalone scripts. Guard SUDO_USER references with ${SUDO_USER:-} for set -u compatibility.
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/build.sh b/build.sh
index 5991828..ea682cf 100755
--- a/build.sh
+++ b/build.sh
@@ -5,7 +5,7 @@
# Uses linux-lts kernel with zfs-dkms from archzfs.com repository.
# DKMS builds ZFS from source, ensuring it always matches the kernel version.
-set -e
+set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROFILE_DIR="$SCRIPT_DIR/profile"
@@ -459,7 +459,7 @@ mkarchiso -v -w "$WORK_DIR" -o "$OUT_DIR" "$PROFILE_DIR"
# Restore ownership to the user who invoked sudo
# mkarchiso runs as root and creates root-owned files
-if [[ -n "$SUDO_USER" ]]; then
+if [[ -n "${SUDO_USER:-}" ]]; then
info "Restoring ownership to $SUDO_USER..."
chown -R "$SUDO_USER:$SUDO_USER" "$OUT_DIR" "$WORK_DIR" "$PROFILE_DIR" 2>/dev/null || true
fi