fix: use test-open for /dev/tty instead of -e check

[[ -e /dev/tty ]] returns true even in non-interactive SSH sessions
where the device file exists but cannot actually be opened, causing
'No such device or address' errors. Replace with { true </dev/tty; }
which tests actual openability before redirecting.
This commit is contained in:
m1ngsama 2026-04-09 22:32:04 +08:00
parent 825633d623
commit 8820d1d107
2 changed files with 5 additions and 3 deletions

6
get.sh
View file

@ -59,8 +59,10 @@ step "Running installer"
cd "$DEST" cd "$DEST"
# exec replaces this process with install.sh and reconnects stdin to /dev/tty # exec replaces this process with install.sh and reconnects stdin to /dev/tty
# so interactive prompts work correctly even when this script was piped from curl # so interactive prompts work correctly even when this script was piped from curl.
if [[ -e /dev/tty ]]; then # Use a test-open to check /dev/tty is actually accessible (it may exist but be
# unusable in non-interactive SSH sessions or container environments).
if { true </dev/tty; } 2>/dev/null; then
exec bash install.sh "$@" </dev/tty exec bash install.sh "$@" </dev/tty
else else
exec bash install.sh "$@" exec bash install.sh "$@"

View file

@ -40,7 +40,7 @@ ask() {
[[ $AUTO_YES -eq 1 ]] && return 0 [[ $AUTO_YES -eq 1 ]] && return 0
if [[ -t 0 ]]; then if [[ -t 0 ]]; then
read -r -p "$1 [y/N] " reply read -r -p "$1 [y/N] " reply
elif [[ -e /dev/tty ]]; then elif { true </dev/tty; } 2>/dev/null; then
read -r -p "$1 [y/N] " reply </dev/tty read -r -p "$1 [y/N] " reply </dev/tty
else else
# No terminal available — default to no (safe) # No terminal available — default to no (safe)