fix(push-host-keys): remove /dev/tty probe, plain read is sufficient

/dev/tty exists as a device node even without a controlling terminal,
so -r/-w tests pass but opening it fails. Plain 'read -r -s' from stdin
is enough: works interactively from a real terminal, and from a non-tty
context the caller should set SUDO_PASS in the environment instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 15:52:09 +10:00
co-authored by Claude Sonnet 4.6
parent cbb86704a3
commit fa53d37360
+2 -9
View File
@@ -66,15 +66,8 @@ prompt_sudo_password() {
sudo_password="$SUDO_PASS" sudo_password="$SUDO_PASS"
return return
fi fi
# Prefer /dev/tty so the prompt works even when stdout/stdin are redirected; read -r -s -p "sudo password for ${SSH_USER} on remote hosts: " sudo_password
# fall back to plain stdin for environments where /dev/tty isn't available. echo >&2
if [[ -r /dev/tty && -w /dev/tty ]]; then
read -r -s -p "sudo password for ${SSH_USER} on remote hosts: " sudo_password < /dev/tty
echo >&2
else
read -r -s -p "sudo password for ${SSH_USER} on remote hosts: " sudo_password
echo >&2
fi
} }
locally_managed_hosts() { locally_managed_hosts() {