Skip to content

Commit c960e3f

Browse files
committed
fix: stop analyze.sh from hanging at interactive prompts
The installer ran the compiled binary with `< /dev/tty` to give piped `curl ... | bash` invocations a terminal. But a `bun build --compile`'d binary can't read raw-mode keypresses from a freshly-opened /dev/tty fd, so every interactive prompt hung with no way to type, arrow, or Ctrl-C out — even for the recommended `bash -c "$(curl ...)"` form, whose stdin was already a working terminal before the redirect replaced it. Run with inherited stdin instead. The command-substitution form keeps a real terminal on stdin and works; the piped form now fails the CLI's TTY gate with a clear 'requires a terminal' message (exit 2) instead of hanging.
1 parent 367beb8 commit c960e3f

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

scripts/analyze.sh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
# temporary directory, printing the path when it finishes. Nothing is installed.
1212
#
1313
# Use the `bash -c "$(curl ...)"` form rather than `curl ... | bash`: the
14-
# command-substitution form leaves your terminal on stdin so the prompts work.
15-
# As a fallback the script also reconnects the controlling terminal (/dev/tty)
16-
# when running the binary, so a piped invocation still gets a TTY.
14+
# command-substitution form leaves your real terminal on stdin so the
15+
# interactive prompts work. A piped (`curl ... | bash`) invocation puts the pipe
16+
# on stdin instead of a terminal, so the CLI's TTY gate refuses to run and asks
17+
# you to re-run it interactively (it does not hang).
1718
#
1819
# Auth is the CLI's job: it reads GITHUB_TOKEN, then GH_TOKEN, then `gh auth
1920
# token`. Export a token first, or be logged in via the gh CLI.
@@ -53,19 +54,14 @@ main() {
5354
[ -f "$_tmp/$BINARY_NAME" ] || fail "expected '$BINARY_NAME' in tarball, not found"
5455
chmod +x "$_tmp/$BINARY_NAME"
5556

56-
# The CLI is an interactive session, so it needs a terminal on stdin.
57-
# Reconnect the controlling terminal (/dev/tty) so prompts work even when this
58-
# script was piped into a shell (stdin = the pipe, not your terminal). Where
59-
# there is no terminal (e.g. CI), run with inherited stdin and let the CLI
60-
# report that it needs one. Run, don't exec, so the EXIT trap still deletes the
61-
# temp binary; preserve the CLI's exit code for the caller.
57+
# Run with inherited stdin and let the CLI's TTY gate handle non-terminals. Do
58+
# NOT redirect `< /dev/tty`: the compiled Bun binary can't read raw-mode
59+
# keypresses from a reopened /dev/tty fd, so prompts would hang with no way to
60+
# Ctrl-C out. Run (not exec) so the EXIT trap deletes the temp binary, and
61+
# forward the CLI's exit code.
6262
info "starting ${BINARY_NAME}..."
6363
set +e
64-
if (: < /dev/tty) 2>/dev/null; then
65-
"$_tmp/$BINARY_NAME" "$@" < /dev/tty
66-
else
67-
"$_tmp/$BINARY_NAME" "$@"
68-
fi
64+
"$_tmp/$BINARY_NAME" "$@"
6965
_status=$?
7066
set -e
7167
exit "$_status"

0 commit comments

Comments
 (0)