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"