fix(install script): ensure script works when piped into bash (#6296)

Signed-off-by: Irbe Krumina <irbekrm@gmail.com>
This commit is contained in:
Irbe Krumina
2026-01-05 07:26:50 +01:00
committed by GitHub
parent 5027164e35
commit c2f5b4cea5
+11 -1
View File
@@ -328,7 +328,17 @@ if [[ ":$PATH:" != *":$GOOSE_BIN_DIR:"* ]]; then
echo "1) Add it for me"
echo "2) I'll add it myself, show instructions"
read -p "Enter choice [1/2]: " choice
# Check whether stdin is a terminal. If it is not (for example, if
# this script has been piped into bash), we need to explicitly read user's
# choice from /dev/tty.
if [ -t 0 ]; then # terminal
read -p "Enter choice [1/2]: " choice
elif [ -r /dev/tty ]; then # not a terminal, but /dev/tty is available
read -p "Enter choice [1/2]: " choice < /dev/tty
else # non-interactive environment without /dev/tty
echo "Non-interactive environment detected without /dev/tty; defaulting to option 2 (show instructions)."
choice=2
fi
case "$choice" in
1)