From 22a661131d38f88e0ae66ae59d6408a9dd7d6cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Wed, 12 Aug 2026 20:27:00 +0000 Subject: [PATCH] page the ? output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The long answer is now well past a screen, so it scrolls the question off the top and the reader lands at a prompt having lost what they were choosing between. Piped through a pager, so it is read a screen at a time and the menu is redrawn underneath it afterwards. `more` rather than `less`: it exits at the end of the file instead of sitting there waiting to be quit, which is right for something asked for once. Only when stdout is a terminal. Redirected or piped — a transcript, a log, the test harness — it comes through whole, since a pager there either blocks or mangles the output. Applied to confirm()'s help hook as well, so every ? in the script pages, not just this one. Verified both ways: driven through a pty it shows --More--, and with output piped all four help sections come through in full. Co-Authored-By: Claude Opus 5 (1M context) --- scripts/setup/machine-setup/lib/base.sh | 17 ++++++++++++++++- scripts/setup/machine-setup/machine-setup.sh | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/setup/machine-setup/lib/base.sh b/scripts/setup/machine-setup/lib/base.sh index 2549383c..22fae105 100644 --- a/scripts/setup/machine-setup/lib/base.sh +++ b/scripts/setup/machine-setup/lib/base.sh @@ -215,6 +215,21 @@ prompt_value() { fi } +# Show long output a screen at a time. +# +# Only when there is a terminal to page on: with output redirected or piped — +# a transcript, a log, the test harness — it has to come through whole, and a +# pager would either block or mangle it. `more` rather than `less` because it +# exits at the end of the file instead of sitting there waiting to be quit, +# which is what you want for something you asked to read once. +page() { + if [[ -t 1 ]] && command -v more &>/dev/null; then + more + else + cat + fi +} + # Ask before acting. Every section that changes the machine goes through this, so # a run is a sequence of things you agreed to rather than a wall of output you # read afterwards to find out what happened. @@ -255,7 +270,7 @@ confirm() { "?") if [[ -n "$help_fn" ]]; then echo "" - "$help_fn" + "$help_fn" | page echo "" else warn "Answer y or n." diff --git a/scripts/setup/machine-setup/machine-setup.sh b/scripts/setup/machine-setup/machine-setup.sh index 6929ecc7..c79b4953 100755 --- a/scripts/setup/machine-setup/machine-setup.sh +++ b/scripts/setup/machine-setup/machine-setup.sh @@ -470,7 +470,7 @@ if ! skip; then 3) TS_PLANE="tailscale" ;; "?") echo "" - tailscale_networks_help + tailscale_networks_help | page echo "" tailscale_network_menu ;;