Browse Source

fix: detect piped execution and provide clear guidance

Problem:
- Running 'curl ... | bash' without arguments showed interactive menu
- But stdin was the curl stream, not terminal
- Script couldn't read user input and would exit silently
- Confusing user experience

Solution:
- Add check_interactive_mode() to detect if stdin is a terminal
- If running in pipe without arguments, show helpful error message
- Provide clear instructions for both interactive and profile-based install
- Update README to clarify installation methods

Changes:
- Add [ ! -t 0 ] check to detect non-terminal stdin
- Show helpful error with examples when piped without profile
- Update README to recommend profile-based install (fastest)
- Clarify that interactive mode requires downloading first

User Experience:
Before: Silent exit or confusing behavior
After: Clear error message with exact commands to run

Examples shown to user:
- Download first: curl ... -o install.sh && bash install.sh
- Or use profile: curl ... | bash -s core

This fixes the issue reported when running on another computer.
darrenhinde 4 months ago
parent
commit
515a83dce2
2 changed files with 51 additions and 14 deletions
  1. 23 14
      README.md
  2. 28 0
      install.sh

+ 23 - 14
README.md

@@ -40,25 +40,37 @@ https://opencode.ai/docs#
 ```
 ### Step 2: Install Agents & Commands
 
-**Option A: Interactive Installer (Recommended)**
+**Option A: Interactive Installer**
+
+> **Note:** Interactive mode requires downloading the script first (can't run through pipe)
 
 <details open>
 <summary><b>macOS / Linux</b></summary>
 
 ```bash
-curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh | bash
+# Download the installer
+curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh -o install.sh
+
+# Run interactively
+bash install.sh
 ```
 </details>
 
 <details>
-<summary><b>Windows</b></summary>
+<summary><b>Windows (Git Bash)</b></summary>
 
-**Using Git Bash (Recommended):**
 ```bash
-curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh | bash
+# Download the installer
+curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh -o install.sh
+
+# Run interactively
+bash install.sh
 ```
+</details>
+
+<details>
+<summary><b>Windows (PowerShell)</b></summary>
 
-**Using PowerShell:**
 ```powershell
 # Download the script
 Invoke-WebRequest -Uri "https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh" -OutFile "install.sh"
@@ -70,11 +82,6 @@ Invoke-WebRequest -Uri "https://raw.githubusercontent.com/darrenhinde/opencode-a
 wsl bash install.sh
 ```
 
-**Using WSL:**
-```bash
-curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh | bash
-```
-
 > **Note:** Git Bash comes with Git for Windows. [Download here](https://git-scm.com/download/win)
 </details>
 
@@ -88,7 +95,9 @@ The installer offers:
 
 > **Updating?** The installer detects existing files and lets you choose: skip existing (keep your changes), overwrite all (get latest), or backup & overwrite (safe update). [Learn more](docs/getting-started/collision-handling.md)
 
-**Option B: Profile-Based Install**
+**Option B: Profile-Based Install (Recommended)**
+
+> **Fastest method:** One command, no interaction needed
 
 <details open>
 <summary><b>macOS / Linux / Git Bash / WSL</b></summary>
@@ -100,10 +109,10 @@ curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/in
 # Balanced for daily development (22 components)
 curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh | bash -s developer
 
-# Everything included (24 components)
+# Everything included (25 components)
 curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh | bash -s full
 
-# Advanced + System Builder (29 components)
+# Advanced + System Builder (23 components)
 curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh | bash -s advanced
 ```
 </details>

+ 28 - 0
install.sh

@@ -203,7 +203,35 @@ resolve_dependencies() {
 # Installation Mode Selection
 #############################################################################
 
+check_interactive_mode() {
+    # Check if stdin is a terminal (not piped from curl)
+    if [ ! -t 0 ]; then
+        print_header
+        print_error "Interactive mode requires a terminal"
+        echo ""
+        echo "You're running this script in a pipe (e.g., curl | bash)"
+        echo "For interactive mode, download the script first:"
+        echo ""
+        echo -e "${CYAN}# Download the script${NC}"
+        echo "curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh -o install.sh"
+        echo ""
+        echo -e "${CYAN}# Run interactively${NC}"
+        echo "bash install.sh"
+        echo ""
+        echo "Or use a profile directly:"
+        echo ""
+        echo -e "${CYAN}# Quick install with profile${NC}"
+        echo "curl -fsSL https://raw.githubusercontent.com/darrenhinde/opencode-agents/main/install.sh | bash -s core"
+        echo ""
+        echo "Available profiles: core, developer, full, advanced"
+        echo ""
+        cleanup_and_exit 1
+    fi
+}
+
 show_main_menu() {
+    check_interactive_mode
+    
     clear
     print_header