From 0aad9c9c55bc93fb4ff95b3006934aa7b7b6d7eb Mon Sep 17 00:00:00 2001 From: timmy Date: Tue, 21 Apr 2026 13:16:12 +0800 Subject: [PATCH] fix(common.sh): use tty open test instead of -r for no-TTY detection macOS /dev/tty passes -r check even when unusable in non-TTY sessions; replace with `true < /dev/tty` probe so confirm_destructive and confirm_exact_match correctly detect missing TTY and emit the expected error message instead of crashing with "Device not configured". --- scripts/lib/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index 8b79031..aba232c 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -158,7 +158,7 @@ confirm_destructive() { if [[ "${GITEA_YES:-0}" == "1" ]]; then return 0 fi - if [[ ! -r /dev/tty ]]; then + if ! { true < /dev/tty; } 2>/dev/null; then log_err "需要確認但無 TTY;請加 -y / --yes 或設定 GITEA_YES=1" exit 1 fi @@ -178,7 +178,7 @@ confirm_exact_match() { if [[ "${GITEA_YES:-0}" == "1" ]]; then return 0 fi - if [[ ! -r /dev/tty ]]; then + if ! { true < /dev/tty; } 2>/dev/null; then log_err "需要確認但無 TTY;請加 -y / --yes 或設定 GITEA_YES=1" exit 1 fi