mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-05-22 03:02:35 +00:00
fix: install script menu selection now works correctly when piped through curl
- Fixed safe_read function to properly handle TTY availability - Added proper error handling for compare_versions return codes - Script no longer exits silently when selecting menu options
This commit is contained in:
parent
6f5abb85c4
commit
ce9c135bc7
1 changed files with 17 additions and 9 deletions
26
install.sh
26
install.sh
|
|
@ -44,15 +44,22 @@ safe_read() {
|
|||
|
||||
# When script is piped (curl | bash), stdin is the pipe, not the terminal
|
||||
# We need to read from /dev/tty for user input
|
||||
if [[ -e /dev/tty ]]; then
|
||||
# TTY is available, read from it
|
||||
echo -n "$prompt" > /dev/tty
|
||||
# Use read with -u to read from file descriptor
|
||||
IFS= read -r "$var_name" < /dev/tty
|
||||
else
|
||||
# No TTY (e.g., in automated environments)
|
||||
if [[ -t 0 ]]; then
|
||||
# stdin is a terminal, read normally
|
||||
echo -n "$prompt"
|
||||
IFS= read -r "$var_name"
|
||||
else
|
||||
# stdin is not a terminal (piped), try /dev/tty if available
|
||||
if { exec 3< /dev/tty; } 2>/dev/null; then
|
||||
# /dev/tty is available and usable
|
||||
echo -n "$prompt"
|
||||
IFS= read -r "$var_name" <&3
|
||||
exec 3<&-
|
||||
else
|
||||
# No TTY available, read from stdin (which may be piped)
|
||||
echo -n "$prompt"
|
||||
IFS= read -r "$var_name"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -1010,8 +1017,9 @@ main() {
|
|||
# Determine if this is an upgrade or downgrade
|
||||
local action_word="Installing"
|
||||
if [[ -n "$CURRENT_VERSION" ]] && [[ "$CURRENT_VERSION" != "unknown" ]]; then
|
||||
compare_versions "$target_version" "$CURRENT_VERSION"
|
||||
case $? in
|
||||
local cmp_result=0
|
||||
compare_versions "$target_version" "$CURRENT_VERSION" || cmp_result=$?
|
||||
case $cmp_result in
|
||||
0) action_word="Reinstalling" ;;
|
||||
1) action_word="Updating to" ;;
|
||||
2) action_word="Downgrading to" ;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue