Keep the installer's build steps from reading its answers

Commands run during the install (distrobox, ssh) read stdin, so answers
typed ahead or piped in were swallowed and the questions fell back to their
defaults. Only the questions read stdin now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DeeJanuzandClaude Opus 5.5 committed 2026-09-26 16:22:29 -06:00
1 parent 983773edbd
commit 932d41af6a
1 file changed
+5 -1
+5 -1
View File
@@ -23,13 +23,17 @@ for arg in "$@"; do
esac esac
done done
# Only the questions read from the terminal (or whatever stdin is); the build steps get
# no input, so they can't swallow typed-ahead or piped answers.
exec 3<&0 </dev/null
step() { printf '\n\033[1m== %s\033[0m\n' "$*"; } step() { printf '\n\033[1m== %s\033[0m\n' "$*"; }
ask() { # ask "question" default(y|n) ask() { # ask "question" default(y|n)
[ "$assume_yes" = 1 ] && [ "$2" = y ] && return 0 [ "$assume_yes" = 1 ] && [ "$2" = y ] && return 0
[ "$assume_yes" = 1 ] && return 1 [ "$assume_yes" = 1 ] && return 1
local hint answer local hint answer
hint=$([ "$2" = y ] && echo "Y/n" || echo "y/N") hint=$([ "$2" = y ] && echo "Y/n" || echo "y/N")
read -r -p "$1 [$hint] " answer read -r -p "$1 [$hint] " answer <&3 || answer=
answer=${answer:-$2} answer=${answer:-$2}
[[ $answer =~ ^[Yy] ]] [[ $answer =~ ^[Yy] ]]
} }