mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix(install script): ensure script works when piped into bash (#6296)
Signed-off-by: Irbe Krumina <irbekrm@gmail.com>
This commit is contained in:
+11
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user