From 417f33ee539708096f5d43444351a5ec66377cbe Mon Sep 17 00:00:00 2001 From: mmelnich Date: Wed, 12 Aug 2026 18:09:36 -0700 Subject: [PATCH] install.sh: draw a real progress bar during the build steps Three rendering tiers, chosen by probing the terminal: 2 a terminal with colour and UTF-8: a bar redrawn in place, block glyphs 1 a terminal without one of those: the same bar in ASCII 0 not a terminal: one line per step, no escapes, no carriage returns Tier 0 is a requirement rather than a fallback. Redirected output becomes install.log, CI transcripts and bug reports, and control characters make all three unreadable, so run_build_step falls straight through to run_step there and the bytes are identical to before this change. CI already asserts that redirected output contains no escape sequence and no carriage return. The bar is determinate. Both build tools already report progress on the stream being captured anyway -- Ninja writes "[12/34]" and Make writes "[ 42%]" -- so it tracks real work rather than elapsed time. A spinner would have conveyed nothing. Steps with no parseable progress keep their existing one-line form rather than growing a fake bar. Implementation note: the parsing loop necessarily runs in a subshell, so the build command's exit status is passed back through a file rather than a variable, and checked explicitly. Verified: redirected output byte-identical and escape-free; under a pty the bar advances through 5%, 20%, 49% during the RandBLAS build and each step resolves to a "done" line. --- install/install.sh | 106 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/install/install.sh b/install/install.sh index d6030c3a..4cf4c869 100755 --- a/install/install.sh +++ b/install/install.sh @@ -170,6 +170,44 @@ else C_OK=""; C_ERR=""; C_WARN=""; C_BOLD=""; C_OFF="" fi +# Progress rendering tier. +# 2 a terminal that can draw: redraw a bar in place, with block characters +# 1 a terminal without colour or UTF-8: same bar, ASCII, still redrawn +# 0 not a terminal: one line per step, no escapes, no carriage returns +# +# Tier 0 is not a fallback, it is a requirement. Redirected output ends up in +# install.log, in CI transcripts and in bug reports, and control characters +# make all three unreadable. CI asserts that redirected output contains no +# escape sequence and no carriage return. +PROGRESS_TIER=0 +if [[ -t 1 && "$WANT_PROGRESS" == "1" && "${TERM:-}" != "dumb" ]]; then + if [[ -z "${NO_COLOR:-}" && "${LC_ALL:-${LC_CTYPE:-${LANG:-}}}" == *[Uu][Tt][Ff]* ]]; then + PROGRESS_TIER=2 + else + PROGRESS_TIER=1 + fi +fi + +if (( PROGRESS_TIER >= 2 )); then + BAR_FULL="━"; BAR_EMPTY="─" +else + BAR_FULL="#"; BAR_EMPTY="-" +fi + +# draw_bar