Skip to content

Commit c22ceba

Browse files
authored
Linux - Fix interactive prompt handling during installation with curl (#2167)
### What changed? - Fixed the interactive prompt not working when installing via piped execution (`curl -L <url> | sh`) - Added proper `/dev/tty` fallback to always allow user input where available - Removed duplicate prompt calls - Improved handling of non-interactive environments with a clear fallback message ### Works in these cases ```sh # ✔ Interactive (TTY prompt works even when piped) curl -L https://example.com/install.sh | sh # ✔ Non-interactive (automation, CI, scripts) curl -L https://example.com/install.sh | sh -s -- -y ``` <img width="1411" height="1505" alt="image" src="https://github.com/user-attachments/assets/2d7b6734-ec3e-4be5-994f-6fb0b7e138f0" />
2 parents ede8541 + 3ab48cd commit c22ceba

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/linux/Packaging.Linux/install-from-source.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,26 @@ if [ -z $is_ci ]; then
4040
4141
Git Credential Manager is licensed under the MIT License: https://aka.ms/gcm/license"
4242

43-
while true; do
44-
read -p "Do you want to continue? [Y/n] " yn
45-
case $yn in
46-
[Yy]*|"")
47-
break
48-
;;
49-
[Nn]*)
50-
exit
51-
;;
52-
*)
53-
echo "Please answer yes or no."
54-
;;
43+
while true; do
44+
# Display prompt once before reading input
45+
printf "Do you want to continue? [Y/n] "
46+
47+
# Prefer reading from the controlling terminal (TTY) when available,
48+
# so that input works even if the script is piped (e.g. curl URL | sh)
49+
if [ -r /dev/tty ]; then
50+
read yn < /dev/tty
51+
# If no TTY is available, attempt to read from standard input (stdin)
52+
elif ! read yn; then
53+
# If input is not possible via TTY or stdin, assume a non-interactive environment
54+
# and abort with guidance for automated usage
55+
echo "Interactive prompt unavailable in this environment. Use 'sh -s -- -y' for automated install."
56+
exit 1
57+
fi
58+
59+
case "$yn" in
60+
[Yy]*|"") break ;;
61+
[Nn]*) exit ;;
62+
*) echo "Please answer yes or no." ;;
5563
esac
5664
done
5765
fi

0 commit comments

Comments
 (0)