fix(web-install): don't hang after 'delegating' in interactive curl|bash (#33)

curl|bash reads this script byte-by-byte from the pipe; a bare `exec < /dev/tty`
then made bash read the NEXT line (the bootstrap exec) from the keyboard →
infinite hang after "delegating", bootstrap never started. Fix: merge the
redirect into the bootstrap exec (one command). Verified piped-under-pty:
buggy=HANG, fixed=full install completes.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
KeiSei84 2026-05-22 11:29:30 +08:00 committed by GitHub
parent 37d249caad
commit f79f28e68a

View file

@ -91,16 +91,20 @@ say "delegating to $KEISEI_ROOT/bootstrap.sh ${PASS_THROUGH[*]:-}"
cd "$KEISEI_ROOT"
# curl|bash сценарий: stdin = pipe от curl, поэтому wizard'у read нечего читать.
# Если /dev/tty реально ОТКРЫВАЕТСЯ (сессия интерактивная), переподключаем stdin
# к терминалу — иначе onboarding/whiptail падают на первом prompt.
# ВАЖНО: `[ -r /dev/tty ]` недостаточно — путь может stat'иться readable, но
# Если /dev/tty реально ОТКРЫВАЕТСЯ (сессия интерактивная), запускаем bootstrap
# со stdin = терминал — иначе onboarding/whiptail падают на первом prompt.
# ВАЖНО #1: `[ -r /dev/tty ]` недостаточно — путь может stat'иться readable, но
# `exec < /dev/tty` падает с "No such device or address" когда нет управляющего
# терминала (ssh non-interactive, CI, cron). Поэтому пробуем реально открыть его
# через `{ : < /dev/tty; }` и реаттачим ТОЛЬКО при успехе. Иначе установка идёт
# неинтерактивно (рассчитано на --yes / KEISEI_SKIP_ONBOARD).
# audit 2026-05-18 bug #4; non-TTY e2e fix 2026-05-21.
# через `{ : < /dev/tty; }` и реаттачим ТОЛЬКО при успехе.
# ВАЖНО #2: bash читает ЭТОТ скрипт из трубы curl ПОБАЙТНО. Отдельный
# `exec < /dev/tty` заставил бы bash читать СЛЕДУЮЩУЮ строку (сам запуск
# bootstrap) уже с клавиатуры → вечный висяк после "delegating". Поэтому редирект
# и exec ОБЯЗАНЫ быть ОДНОЙ командой: подменили stdin и сразу заменили процесс —
# bash больше не читает ни байта скрипта из (уже не той) трубы.
# audit 2026-05-18 bug #4; non-TTY e2e fix 2026-05-21; curl|bash hang fix 2026-05-22.
if [ ! -t 0 ] && { : < /dev/tty; } 2>/dev/null; then
exec < /dev/tty
exec ./bootstrap.sh "${PASS_THROUGH[@]}" < /dev/tty
fi
exec ./bootstrap.sh "${PASS_THROUGH[@]}"