From cc847cff67d01e4037884a56bc72d1e5ef13b84f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Mar 2026 13:37:29 +0000 Subject: [PATCH] Wrap script in main() to prevent line-by-line execution bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When run via `bash <(curl ...)`, bash reads the script incrementally from a process substitution fd. If a `read < /dev/tty` call disrupts the fd state, bash can lose its place and the remaining script lines get fed to the interactive shell prompt as individual commands. Wrapping everything in main() forces bash to parse the entire script into memory before executing any of it — the standard fix for curl-piped scripts. Also changed README one-liner to download-then-execute pattern (curl -o /tmp/... && bash /tmp/...) as a belt-and-suspenders approach. https://claude.ai/code/session_01XKYC1basxdwtHy71tky7xm --- README.md | 2 +- setup-openwhispr.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6e4075..a940e6d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Quick install ```bash -bash <(curl -fsSL https://raw.githubusercontent.com/outis1one/openwhispr-easy-setup/main/setup-openwhispr.sh) +curl -fsSL https://raw.githubusercontent.com/outis1one/openwhispr-easy-setup/main/setup-openwhispr.sh -o /tmp/setup-openwhispr.sh && bash /tmp/setup-openwhispr.sh ``` Or clone and run: diff --git a/setup-openwhispr.sh b/setup-openwhispr.sh index af3e367..d65c627 100755 --- a/setup-openwhispr.sh +++ b/setup-openwhispr.sh @@ -3,6 +3,14 @@ # https://github.com/outis1one/openwhispr-easy-setup # License: MIT +# ── Wrap everything in main() so bash reads the entire script before executing. +# This prevents the "line-by-line interpreted as commands" bug when run via: +# bash <(curl -fsSL ...) or curl ... | bash +# Without this wrapper, bash may lose track of the script source after a read +# from /dev/tty and start feeding remaining script lines to the shell prompt. + +main() { + # Do NOT use set -e — we handle errors explicitly readonly SCRIPT_VERSION="1.0.0" @@ -653,3 +661,8 @@ cat <