mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-10 19:10:59 +08:00
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:
parent
825633d623
commit
8820d1d107
2 changed files with 5 additions and 3 deletions
6
get.sh
6
get.sh
|
|
@ -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 "$@"
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue