Wrap script in main() to prevent line-by-line execution bug
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
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
## Quick install
|
## Quick install
|
||||||
|
|
||||||
```bash
|
```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:
|
Or clone and run:
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
# https://github.com/outis1one/openwhispr-easy-setup
|
# https://github.com/outis1one/openwhispr-easy-setup
|
||||||
# License: MIT
|
# 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
|
# Do NOT use set -e — we handle errors explicitly
|
||||||
|
|
||||||
readonly SCRIPT_VERSION="1.0.0"
|
readonly SCRIPT_VERSION="1.0.0"
|
||||||
@@ -653,3 +661,8 @@ cat <<EOF
|
|||||||
EOF
|
EOF
|
||||||
divider
|
divider
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
|
||||||
|
} # end main()
|
||||||
|
|
||||||
|
# Call main — this ensures the entire script is parsed before execution
|
||||||
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user