From 7505d08dbcbc23aa1d949dac00e643929e4a083c Mon Sep 17 00:00:00 2001 From: uroma Date: Thu, 22 Jan 2026 16:19:49 +0000 Subject: [PATCH] Fix: Interactive input not working with curl | bash All `read -p` commands now redirect stdin from /dev/tty instead of piped stdin. This fixes the bug where menu prompts immediately failed with "Invalid choice" when script was executed via curl | bash. Fixed 10 read commands throughout the script: - Provider selection menu - API key input prompts - Installation confirmation prompts - Coding-helper installation prompts Co-Authored-By: Claude --- install-claude-code.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install-claude-code.sh b/install-claude-code.sh index 3905190..08dad26 100755 --- a/install-claude-code.sh +++ b/install-claude-code.sh @@ -138,7 +138,7 @@ install_claude_code() { local current_version=$(claude --version 2>/dev/null | head -1 || echo "unknown") log_info "Claude Code already installed: $current_version" echo "" - read -p "Update to latest version? [y/N] " -n 1 -r + read -p "Update to latest version? [y/N] " -n 1 -r < /dev/tty echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then log_info "Updating Claude Code..." @@ -225,7 +225,7 @@ switch_provider() { echo " 3) Update API key only (keep current provider)" echo " 4) Skip configuration" echo "" - read -p "Choose option [1-4]: " -n 1 -r provider_choice + read -p "Choose option [1-4]: " -n 1 -r provider_choice < /dev/tty echo "" echo "" @@ -264,7 +264,7 @@ configure_zai_api() { echo -e "${MAGENTA}Your API key format is: ${BOLD}your-api-key-here${NC}" echo "" - read -p "Enter your Z.AI API key (or press Enter to skip): " -r API_KEY + read -p "Enter your Z.AI API key (or press Enter to skip): " -r API_KEY < /dev/tty echo "" if [ -z "$API_KEY" ]; then @@ -287,7 +287,7 @@ configure_anthropic_api() { echo -e "${MAGENTA}Your API key format is: ${BOLD}sk-ant-api03-...${NC}" echo "" - read -p "Enter your Anthropic API key (or press Enter to skip): " -r API_KEY + read -p "Enter your Anthropic API key (or press Enter to skip): " -r API_KEY < /dev/tty echo "" if [ -z "$API_KEY" ]; then @@ -320,7 +320,7 @@ update_api_key_only() { echo "Which provider's API key do you want to update?" echo " 1) Z.AI" echo " 2) Anthropic" - read -p "Choose [1-2]: " -n 1 -r key_choice + read -p "Choose [1-2]: " -n 1 -r key_choice < /dev/tty echo "" case $key_choice in 1) current_provider="zai" ;; @@ -330,7 +330,7 @@ update_api_key_only() { ;; esac - read -p "Enter new API key: " -r API_KEY + read -p "Enter new API key: " -r API_KEY < /dev/tty echo "" if [ -z "$API_KEY" ]; then @@ -507,7 +507,7 @@ offer_coding_helper_addons() { echo " • Automatic tool detection and installation" echo " • Configuration backup and sync" echo "" - read -p "Install Z.AI coding-helper? [y/N] " -n 1 -r install_helper + read -p "Install Z.AI coding-helper? [y/N] " -n 1 -r install_helper < /dev/tty echo "" if [[ ! $install_helper =~ ^[Yy]$ ]]; then @@ -525,7 +525,7 @@ install_coding_helper() { if check_coding_helper_installed; then log_info "coding-helper already installed" echo "" - read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper + read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty echo "" if [[ $launch_helper =~ ^[Yy]$ ]]; then launch_coding_helper @@ -539,7 +539,7 @@ install_coding_helper() { echo "" echo -e "${CYAN}You can now run:${NC} ${YELLOW}chelper${NC} ${CYAN}or${NC} ${YELLOW}npx @z_ai/coding-helper${NC}" echo "" - read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper + read -p "Launch coding-helper wizard now? [y/N] " -n 1 -r launch_helper < /dev/tty echo "" if [[ $launch_helper =~ ^[Yy]$ ]]; then launch_coding_helper @@ -747,7 +747,7 @@ main() { echo " 2) Anthropic (Official Claude Models)" echo " 3) Skip for now" echo "" - read -p "Choose option [1-3]: " -n 1 -r initial_choice + read -p "Choose option [1-3]: " -n 1 -r initial_choice < /dev/tty echo "" echo ""