From a5e4facf42622f225823ea4b6f7b4c9d81040dd4 Mon Sep 17 00:00:00 2001 From: Pathfinder Date: Mon, 2 Nov 2026 16:19:52 +0100 Subject: [PATCH] Live progress line: clamp to terminal width MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit YuKu's promised screenshot revealed the real section-6 chaos: the live line 'block + msg + current package' is longer than 80 columns, so every redraw WRAPPED to a new line instead of overwriting — the screen filled with duplicate partial progress lines. The line is now composed once and clamped to $(tput cols) - 2 with an ASCII '..' tail. 80-col pty run: zero wrapped live lines (the only >82-char output left is plain-mode dnf, unchanged by design). --- lib/common.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 219d35b..acfa991 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -143,19 +143,25 @@ ui_quiet_run() { cur=$(sed -n "$((before+1)),\$p" "$log" 2>/dev/null \ | grep -E '^(Installing|Upgrading|Downgrading|Removing|Verifying|Preparing|Cleanup):' \ | tail -n 1 || true) + # Compose ONCE, then clamp to the terminal width: a live line longer + # than the screen wraps on every redraw and floods the screen with + # duplicate partial lines (VM-proven on the 80-col TTY). + local cols line + cols=$(tput cols 2>/dev/null) + [[ "$cols" =~ ^[0-9]+$ ]] || cols=80 + if [[ -n "$cur" ]]; then + line="$msg: $cur" + else + line="$msg" + fi + if (( ${#line} > cols - 2 )); then + line="${line:0:cols-4}.." + fi if (( depth >= 16 )); then local code="${bg[$(( f % ${#bg[@]} ))]}" - if [[ -n "$cur" ]]; then - printf '\r\033[%sm \033[0m %s: %s' "$code" "$msg" "$cur" >&2 - else - printf '\r\033[%sm \033[0m %s' "$code" "$msg" >&2 - fi + printf '\r\033[%sm \033[0m %s' "$code" "$line" >&2 else - if [[ -n "$cur" ]]; then - printf '\r %s %s: %s' "${ch[$(( f % ${#ch[@]} ))]}" "$msg" "$cur" >&2 - else - printf '\r %s %s' "${ch[$(( f % ${#ch[@]} ))]}" "$msg" >&2 - fi + printf '\r %s %s' "${ch[$(( f % ${#ch[@]} ))]}" "$line" >&2 fi f=$(( f + 1 )) sleep "$tick"