fix(install): handle piped bash by redirecting stdin to /dev/tty (#315)

When running via `curl | bash`, stdin (fd 0) is the pipe — not the
terminal. The script was setting INTERACTIVE_MODE='ask' and then trying
to `read` from the pipe, which returned EOF/garbage, defaulting to
interactive mode, which then immediately errored because there was no TTY.

Fix: if stdin is a pipe but /dev/tty is accessible, do `exec < /dev/tty`
to redirect stdin to the real terminal so user prompts work correctly.
If there is truly no terminal (headless/CI), fall back to automatic mode
without erroring.

Also fix the misleading error message which suggested running the exact
same curl|bash command that just failed.
This commit is contained in:
Jatin K Malik
2026-03-14 14:16:17 -07:00
committed by GitHub
parent 81623ca6d3
commit 6bdbb3deb4
+12 -6
View File
@@ -113,11 +113,17 @@ HAS_VULKAN="no"
VULKAN_DEVICE=""
# Detect if running non-interactively (e.g., via curl | bash)
# Interactive mode is now default, so only auto-detect non-interactive for curl pipes
# If stdin is a pipe but /dev/tty exists, redirect stdin so user input works normally.
# If no terminal is available at all (headless/CI), fall back to automatic mode.
if [ ! -t 0 ]; then
# When piped via curl, we'll still try to be interactive if possible
# User can force non-interactive with --auto
INTERACTIVE_MODE="ask"
if [ -e /dev/tty ] && [ -r /dev/tty ]; then
exec < /dev/tty
INTERACTIVE_MODE="ask"
else
AUTO_MODE="yes"
INTERACTIVE_MODE="no"
NON_INTERACTIVE="yes"
fi
fi
while [[ $# -gt 0 ]]; do
@@ -1089,8 +1095,8 @@ if [[ "$INTERACTIVE_MODE" == "yes" ]]; then
# Check if we have a TTY (required for interactive mode)
if [ ! -t 0 ]; then
print_error "Interactive mode requires a terminal (TTY)."
print_error "Please run from a terminal, or use automatic mode:"
print_error " curl -fsSL https://raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install.sh | bash"
print_error "Download and run the installer directly from a terminal:"
print_error " curl -fsSL https://raw.githubusercontent.com/jatinkrmalik/vocalinux/main/install.sh -o /tmp/vl.sh && bash /tmp/vl.sh"
exit 1
fi