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 <noreply@anthropic.com>
This commit is contained in:
uroma
2026-01-22 16:19:49 +00:00
Unverified
parent 2ad21eb5d1
commit 7505d08dbc

View File

@@ -138,7 +138,7 @@ install_claude_code() {
local current_version=$(claude --version 2>/dev/null | head -1 || echo "unknown") local current_version=$(claude --version 2>/dev/null | head -1 || echo "unknown")
log_info "Claude Code already installed: $current_version" log_info "Claude Code already installed: $current_version"
echo "" 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 "" echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then if [[ $REPLY =~ ^[Yy]$ ]]; then
log_info "Updating Claude Code..." log_info "Updating Claude Code..."
@@ -225,7 +225,7 @@ switch_provider() {
echo " 3) Update API key only (keep current provider)" echo " 3) Update API key only (keep current provider)"
echo " 4) Skip configuration" echo " 4) Skip configuration"
echo "" 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 ""
echo "" echo ""
@@ -264,7 +264,7 @@ configure_zai_api() {
echo -e "${MAGENTA}Your API key format is: ${BOLD}your-api-key-here${NC}" echo -e "${MAGENTA}Your API key format is: ${BOLD}your-api-key-here${NC}"
echo "" 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 "" echo ""
if [ -z "$API_KEY" ]; then 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 -e "${MAGENTA}Your API key format is: ${BOLD}sk-ant-api03-...${NC}"
echo "" 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 "" echo ""
if [ -z "$API_KEY" ]; then 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 "Which provider's API key do you want to update?"
echo " 1) Z.AI" echo " 1) Z.AI"
echo " 2) Anthropic" 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 "" echo ""
case $key_choice in case $key_choice in
1) current_provider="zai" ;; 1) current_provider="zai" ;;
@@ -330,7 +330,7 @@ update_api_key_only() {
;; ;;
esac esac
read -p "Enter new API key: " -r API_KEY read -p "Enter new API key: " -r API_KEY < /dev/tty
echo "" echo ""
if [ -z "$API_KEY" ]; then if [ -z "$API_KEY" ]; then
@@ -507,7 +507,7 @@ offer_coding_helper_addons() {
echo " • Automatic tool detection and installation" echo " • Automatic tool detection and installation"
echo " • Configuration backup and sync" echo " • Configuration backup and sync"
echo "" 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 "" echo ""
if [[ ! $install_helper =~ ^[Yy]$ ]]; then if [[ ! $install_helper =~ ^[Yy]$ ]]; then
@@ -525,7 +525,7 @@ install_coding_helper() {
if check_coding_helper_installed; then if check_coding_helper_installed; then
log_info "coding-helper already installed" log_info "coding-helper already installed"
echo "" 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 "" echo ""
if [[ $launch_helper =~ ^[Yy]$ ]]; then if [[ $launch_helper =~ ^[Yy]$ ]]; then
launch_coding_helper launch_coding_helper
@@ -539,7 +539,7 @@ install_coding_helper() {
echo "" echo ""
echo -e "${CYAN}You can now run:${NC} ${YELLOW}chelper${NC} ${CYAN}or${NC} ${YELLOW}npx @z_ai/coding-helper${NC}" echo -e "${CYAN}You can now run:${NC} ${YELLOW}chelper${NC} ${CYAN}or${NC} ${YELLOW}npx @z_ai/coding-helper${NC}"
echo "" 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 "" echo ""
if [[ $launch_helper =~ ^[Yy]$ ]]; then if [[ $launch_helper =~ ^[Yy]$ ]]; then
launch_coding_helper launch_coding_helper
@@ -747,7 +747,7 @@ main() {
echo " 2) Anthropic (Official Claude Models)" echo " 2) Anthropic (Official Claude Models)"
echo " 3) Skip for now" echo " 3) Skip for now"
echo "" 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 ""
echo "" echo ""