Skip to content

Conversation

@srperens
Copy link
Collaborator

@srperens srperens commented Dec 1, 2025

Summary

Automatically detect when the script is piped and enable automated mode, preventing the script from hanging while trying to read user input.

Problem

When running:

curl -sSL https://raw.githubusercontent.com/Eyevinn/strom/main/install.sh | bash

The script would:

  1. Show the interactive configuration menu
  2. Try to read input with read -r choice
  3. Hang/exit immediately because stdin is the pipe from curl (not the terminal)
  4. User couldn't interact with the menu or proceed with installation

Root Cause

When piping to bash (curl ... | bash), stdin is connected to the pipe output from curl, not the user's terminal. The read command cannot get keyboard input.

Solution

Added detection in show_config_menu():

# Auto-enable AUTO_INSTALL if stdin is not a terminal (piped from curl)
if [ ! -t 0 ]; then
    log_warning "Stdin is not a terminal (script is piped)"
    log_info "Automatically enabling AUTO_INSTALL mode..."
    log_info "For interactive mode, use: bash <(curl -sSL ...)"
    echo ""
    AUTO_INSTALL="true"
    return
fi

Behavior After Fix

Interactive Mode (stdin is terminal):

bash <(curl -sSL .../install.sh)
  • Shows configuration menu
  • User can interact and customize settings
  • Recommended for humans

Automated Mode (stdin is piped):

curl -sSL .../install.sh | bash
  • Detects piped stdin
  • Automatically enables AUTO_INSTALL
  • Shows friendly message
  • Proceeds with defaults
  • Works for quick installs and CI/CD

Example Output

When piped:

==> Strom Installer

==> Detected: linux-x86_64
==> Stdin is not a terminal (script is piped)
==> Automatically enabling AUTO_INSTALL mode...
==> For interactive mode, use: bash <(curl -sSL ...)

==> Version: v0.2.5
==> Installing GStreamer (full)...

Testing

# Test automated (should skip menu)
docker run -it ubuntu:20.04 bash -c "
  apt-get update && apt-get install -y curl &&
  curl -sSL .../install.sh | bash
"

# Test interactive (should show menu)
docker run -it ubuntu:20.04 bash -c "
  apt-get update && apt-get install -y curl &&
  bash <(curl -sSL .../install.sh)
"

🤖 Generated with Claude Code

When the script is piped to bash (curl ... | bash), stdin is not
available for interactive input. Detect this and automatically
enable AUTO_INSTALL mode.

Changes:
- Check if stdin is a terminal ([ ! -t 0 ])
- Auto-enable AUTO_INSTALL when piped
- Show helpful message explaining why and how to use interactive mode
- Update documentation to clarify both modes

This fixes the issue where:
  curl ... | bash would show menu but couldn't read input

Now it works as expected:
  bash <(curl ...) = Interactive menu (stdin available)
  curl ... | bash = Automated mode (stdin is pipe)

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

Co-Authored-By: Claude <noreply@anthropic.com>
@srperens srperens merged commit ae70e5b into main Dec 1, 2025
@srperens srperens deleted the fix/detect-piped-stdin branch December 1, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants