Live progress line: clamp to terminal width
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).
This commit is contained in:
+16
-10
@@ -143,19 +143,25 @@ ui_quiet_run() {
|
|||||||
cur=$(sed -n "$((before+1)),\$p" "$log" 2>/dev/null \
|
cur=$(sed -n "$((before+1)),\$p" "$log" 2>/dev/null \
|
||||||
| grep -E '^(Installing|Upgrading|Downgrading|Removing|Verifying|Preparing|Cleanup):' \
|
| grep -E '^(Installing|Upgrading|Downgrading|Removing|Verifying|Preparing|Cleanup):' \
|
||||||
| tail -n 1 || true)
|
| 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
|
if (( depth >= 16 )); then
|
||||||
local code="${bg[$(( f % ${#bg[@]} ))]}"
|
local code="${bg[$(( f % ${#bg[@]} ))]}"
|
||||||
if [[ -n "$cur" ]]; then
|
printf '\r\033[%sm \033[0m %s' "$code" "$line" >&2
|
||||||
printf '\r\033[%sm \033[0m %s: %s' "$code" "$msg" "$cur" >&2
|
|
||||||
else
|
|
||||||
printf '\r\033[%sm \033[0m %s' "$code" "$msg" >&2
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [[ -n "$cur" ]]; then
|
printf '\r %s %s' "${ch[$(( f % ${#ch[@]} ))]}" "$line" >&2
|
||||||
printf '\r %s %s: %s' "${ch[$(( f % ${#ch[@]} ))]}" "$msg" "$cur" >&2
|
|
||||||
else
|
|
||||||
printf '\r %s %s' "${ch[$(( f % ${#ch[@]} ))]}" "$msg" >&2
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
f=$(( f + 1 ))
|
f=$(( f + 1 ))
|
||||||
sleep "$tick"
|
sleep "$tick"
|
||||||
|
|||||||
Reference in New Issue
Block a user