From acf0ea4649fde4a1e7bb352ffbba223ef0f84af4 Mon Sep 17 00:00:00 2001 From: Marco Gallegos Date: Fri, 21 Nov 2025 07:35:44 -0600 Subject: [PATCH] refactor: update `read_menu_choice` to use `read -p` and `REPLY` for interactive input. --- vanity_setup.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/vanity_setup.sh b/vanity_setup.sh index fcab9e4..81c0526 100644 --- a/vanity_setup.sh +++ b/vanity_setup.sh @@ -209,19 +209,20 @@ install_docker_stack() { read_menu_choice() { local prompt="$1" - local response="" - printf "%s" "$prompt" if [ -t 0 ]; then - if read -r response; then + if read -r -p "$prompt" REPLY; then printf "\n" - printf '%s\n' "$response" return 0 fi - elif [ -r /dev/tty ]; then - if read -r response < /dev/tty; then + printf "\n" + return 1 + fi + + if [ -r /dev/tty ]; then + printf "%s" "$prompt" > /dev/tty + if read -r REPLY < /dev/tty; then printf "\n" - printf '%s\n' "$response" return 0 fi fi @@ -238,7 +239,9 @@ main_menu() { echo " Q) Salir" echo "" local choice="" - if ! choice="$(read_menu_choice "Opción [A/C/D/Q]: ")"; then + if read_menu_choice "Opción [A/C/D/Q]: "; then + choice="$REPLY" + else echo "No se detecta una entrada interactiva; se seleccionará la opción 'A' por defecto." choice="A" fi