From 9e34b9cbb93427dec933ebccd53276977585b852 Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Sat, 25 Jul 2026 15:55:06 +1000 Subject: [PATCH] fix(push-host-keys): detect non-interactive stdin, direct to SUDO_PASS read exits non-zero when stdin is not a terminal (set -e killed the script silently). Catch that and emit a clear error pointing to the SUDO_PASS environment variable rather than crashing with no output. Co-Authored-By: Claude Sonnet 4.6 --- scripts/secrets/push-host-keys.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/secrets/push-host-keys.sh b/scripts/secrets/push-host-keys.sh index 7dc8d88..7fa08d0 100755 --- a/scripts/secrets/push-host-keys.sh +++ b/scripts/secrets/push-host-keys.sh @@ -66,7 +66,14 @@ prompt_sudo_password() { sudo_password="$SUDO_PASS" return fi - read -r -s -p "sudo password for ${SSH_USER} on remote hosts: " sudo_password + # read exits non-zero when stdin is not a terminal (e.g. CI, background + # agents). Catch that and give a clear message rather than a silent exit. + if ! read -r -s -p "sudo password for ${SSH_USER} on remote hosts: " sudo_password; then + echo >&2 + echo "ERROR: stdin is not a terminal -- cannot prompt for sudo password." >&2 + echo " Set SUDO_PASS= in the environment and re-run." >&2 + exit 1 + fi echo >&2 }