From 8734136908b39f0b748b40375d373798205c0dd6 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Thu, 21 May 2026 20:46:50 -0400 Subject: [PATCH] configurator/shim: drain tty without hanging (use -t 0.05, not -t 0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bash's `read -t 0` only TESTS whether input is available; it does not consume the bytes. So the drain loop `while read -t 0 ...; do :; done` spun forever the moment any bytes were pending (e.g., the DSR reply sitting in the tty input buffer after gum style sent CSI 6n). That hung the configurator at the first step() title screen — blank prompt, blinking cursor, no keyboard form. Use `read -t 0.05 -N 9999` once, which consumes up to 9999 bytes with a 50ms timeout. Always returns after 50ms whether there's data or not. Single call replaces the while loop. --- configs/airootfs/root/.automated_script.sh | 7 ++++--- configs/airootfs/root/configurator | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/configs/airootfs/root/.automated_script.sh b/configs/airootfs/root/.automated_script.sh index e80f094..0f21130 100644 --- a/configs/airootfs/root/.automated_script.sh +++ b/configs/airootfs/root/.automated_script.sh @@ -38,9 +38,10 @@ mkdir -p /var/log touch "$OMARCHY_INSTALL_LOG_FILE" # Drain any stale terminal input (e.g., cursor-position-report responses left -# in the kernel tty input buffer by archiso's boot init). If we don't, the -# first gum invocation can echo them as visible "^[[13;1R" artifacts. -while IFS= read -r -t 0 -n 1024 _drain /dev/null; do :; done +# in the kernel tty input buffer by archiso's boot init). `read -t 0` only +# tests for input; we need a small positive timeout so the read actually +# consumes bytes and then returns. +read -r -t 0.05 -N 9999 _drain /dev/null || true cd /root ./configurator >/dev/tty 2>/dev/tty diff --git a/configs/airootfs/root/configurator b/configs/airootfs/root/configurator index dbd6183..d0cff10 100644 --- a/configs/airootfs/root/configurator +++ b/configs/airootfs/root/configurator @@ -17,7 +17,10 @@ abort() { # that gum's TUI startup sends but doesn't always consume. Without this, # bytes like ^[[13;1R show up next to step titles. _drain_tty() { - while IFS= read -r -t 0 -n 1024 _drain /dev/null; do :; done + # Consume up to 9999 bytes of pending tty input with a short timeout. + # `read -t 0` only TESTS for input; it doesn't consume — that pattern + # hangs forever the moment any data is actually pending. + read -r -t 0.05 -N 9999 _drain /dev/null || true } step() {