fix: Display installation mode menu in Install-Claude.sh

- Redirect menu prompts to stderr to prevent capture by command substitution
- Fixes issue where installation options were not visible to user
- Menu now displays correctly: "Global" and "Path" installation modes

Issue: When get_user_choice output was captured by $(command),
the menu display was suppressed because stdout was being captured.

Solution: Output all user-facing prompts to stderr (&2) while
keeping the selected value on stdout for function return.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-10-01 22:31:33 +08:00
parent f3c1061d1e
commit d6f857ffa8

View File

@@ -119,19 +119,22 @@ function get_user_choice() {
local default_index=0
if [ "$NON_INTERACTIVE" = true ]; then
write_color "Non-interactive mode: Using default '${options[$default_index]}'" "$COLOR_INFO"
write_color "Non-interactive mode: Using default '${options[$default_index]}'" "$COLOR_INFO" >&2
echo "${options[$default_index]}"
return
fi
echo ""
write_color "$prompt" "$COLOR_PROMPT"
echo ""
# Output prompts to stderr so they don't interfere with function return value
echo "" >&2
write_color "$prompt" "$COLOR_PROMPT" >&2
echo "" >&2
for i in "${!options[@]}"; do
echo " $((i + 1)). ${options[$i]}"
echo " $((i + 1)). ${options[$i]}" >&2
done
echo "" >&2
while true; do
read -p "Please select (1-${#options[@]}): " choice
@@ -140,7 +143,7 @@ function get_user_choice() {
return
fi
write_color "Invalid selection. Please enter a number between 1 and ${#options[@]}" "$COLOR_WARNING"
write_color "Invalid selection. Please enter a number between 1 and ${#options[@]}" "$COLOR_WARNING" >&2
done
}