From ee1082945266c6275123fd5d008a036b5a6fc715 Mon Sep 17 00:00:00 2001 From: Pathfinder Date: Wed, 11 Nov 2026 15:46:45 +0100 Subject: [PATCH] Cosmetic: ANSI line wipe; hide (0 packages) on idempotent re-runs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two nits from YuKu's laptop paste: the 100-space line wipe left a visible gap before short summaries (now ANSI EL: \r\033[K, no residue), and '(0 packages)' printed when nothing new was installed (idempotent re-run / theme deps all present) — the count parenthetical is now omitted when zero. --- lib/common.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 307ee52..75484bf 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -173,18 +173,26 @@ ui_quiet_run() { local rc=0 wait "$pid" || rc=$? - printf '\r%*s\r' 100 '' >&2 + # ANSI erase-line: wipes the live line without leaving trailing spaces + # (a 100-space wipe left a visible gap when the summary was shorter) + printf '\r\033[K' >&2 if (( rc == 0 )); then n=$(sed -n "$((before+1)),\$p" "$log" 2>/dev/null | grep -ac '^Installing' || true) - local plural="s" - (( n == 1 )) && plural="" + local count_txt="" + if (( n > 0 )); then + local plural="s" + (( n == 1 )) && plural="" + count_txt=" (${n} package${plural})" + fi + # n == 0 means nothing new was installed (idempotent re-run / + # deps already present): print the message without a count. if (( depth == 256 )); then - printf '\033[48;5;34m \033[0m %s (%s package%s)\n' "$msg" "$n" "$plural" >&2 + printf '\033[48;5;34m \033[0m %s%s\n' "$msg" "$count_txt" >&2 elif (( depth == 16 )); then - printf '\033[42m \033[0m %s (%s package%s)\n' "$msg" "$n" "$plural" >&2 + printf '\033[42m \033[0m %s%s\n' "$msg" "$count_txt" >&2 else - ok "$msg (${n} package${plural})" + ok "$msg${count_txt}" fi return 0 else