aboutsummaryrefslogtreecommitdiffstats
path: root/.extras/hooks
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-20 11:24:20 +0200
committerDanilo M. <danix@danix.xyz>2026-06-20 11:24:20 +0200
commit5583e2e7aea4c730858de1609626fa6afa383586 (patch)
tree7a0ae9efb4c150b994b15ccd50b2595b375ea006 /.extras/hooks
parent1d0e0de406f0e360dad3e28c7e55df3ef243abd3 (diff)
downloadmy-slackbuilds-5583e2e7aea4c730858de1609626fa6afa383586.tar.gz
my-slackbuilds-5583e2e7aea4c730858de1609626fa6afa383586.zip
hooks: harden post-commit against missing tty
Skip the archive prompt cleanly when /dev/tty is unreadable (e.g. non-interactive commits) instead of crashing under set -u on an unbound answer variable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to '.extras/hooks')
-rwxr-xr-x.extras/hooks/post-commit8
1 files changed, 7 insertions, 1 deletions
diff --git a/.extras/hooks/post-commit b/.extras/hooks/post-commit
index 9f92e3c..6350615 100755
--- a/.extras/hooks/post-commit
+++ b/.extras/hooks/post-commit
@@ -31,8 +31,14 @@ for pkg in "${PACKAGES[@]}"; do
printf '%s\n' "${f#"$REPO_ROOT/"}"
done < <(find "$REPO_ROOT/$pkg" -type f | sort)
echo ""
+ # Need an interactive terminal to prompt; skip cleanly if none.
+ if [ ! -r /dev/tty ]; then
+ echo " -> No terminal, skipped (run hook interactively to archive)."
+ continue
+ fi
printf "Create SBo archive for '%s'? [y/N] " "$pkg"
- read -r answer </dev/tty
+ answer=""
+ read -r answer </dev/tty || answer=""
case "$answer" in
[yY]|[yY][eE][sS])
mkdir -p "$SBO_DIR"