From cf66198dc5b5db1db52c88d5fa9ac2a9d2a0be5b Mon Sep 17 00:00:00 2001 From: Rob Masson Date: Tue, 20 Oct 2026 16:43:57 -0700 Subject: [PATCH] fix(installer): Ctrl-C at a menu exits under macOS bash 3.2 bash 3.2 (macOS /bin/bash) restarts a read that a trapped SIGINT interrupts and runs the trap only after the read returns. Ctrl-C at an arrow-key menu therefore waited for another key instead of exiting 130, which made test_interrupt_at_a_prompt_restores_the_terminal flaky on the macOS zsh runner (1 pass in 6 locally with /bin/bash). The menu now reads each key with a one-second timeout in a loop, so the INT trap runs between reads. Co-Authored-By: Claude Opus 5.5 --- install.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index c04eddf..509404b 100755 --- a/install.sh +++ b/install.sh @@ -330,6 +330,19 @@ spin() { # --------------------------------------------------------------------------- CHOICE=0 +KEY="" + +# Read one key into KEY. bash 3.2 (macOS /bin/bash) restarts a read that a +# trapped SIGINT interrupts and runs the trap only once the read returns, so +# Ctrl-C at a menu would wait for another key. A one-second timeout lets the +# INT trap run between reads. End of input reads as Enter. +read_key() { + KEY="" + while :; do + IFS= read -rsn1 -t 1 KEY <"Label|hint">... # Arrow keys or j/k move, Enter selects, digits jump. Sets CHOICE. @@ -375,8 +388,8 @@ choose() { done printf '\033[2K%s%s%s move %s select%s' "$PAD" "$C_DIM" "$(glyph '↑↓' 'j/k')" "$(glyph '↵' 'enter')" "$RESET" - key="" - IFS= read -rsn1 key