fix(logging): use col -bp to collapse progress bar redraws in AUR logs

script(1) captures every \r-redrawn frame of the pacman progress bar
as raw bytes. The previous sed pass only stripped ANSI codes, leaving
all intermediate frames concatenated in the log. col -bp semantically
replays the carriage-return overwrites and retains only the final state
of each line; the sed pass then strips residual ANSI codes and the
"Script started/done" header that script(1) writes to the file even
under -q. Bump wrapper version to 3.
This commit is contained in:
2026-06-11 22:10:19 -04:00
parent 0cbb7c6892
commit fc63b4f1b0
2 changed files with 14 additions and 6 deletions
+7 -3
View File
@@ -20,7 +20,7 @@ end
set -l _paru_real /usr/bin/paru
set -l _paru_wrapper "$HOME/.local/bin/paru"
set -l _paru_wrapper_version 2
set -l _paru_wrapper_version 3
# Skip entirely if the real paru binary isn't present
test -x $_paru_real; or return
@@ -54,8 +54,12 @@ printf '%s\n' \
'script -q -e -c "$cmd_str" "$log_file"' \
'exit_code=$?' \
'' \
'# Strip ANSI escape sequences and carriage returns for readable plain-text logs.' \
'sed -i '"'"'s/\x1b\[[0-9;?]*[a-zA-Z]//g; s/\r//g'"'"' "$log_file" 2>/dev/null || true' \
'# col -bp collapses CR-redrawn progress bar frames; sed strips ANSI codes and script(1) headers.' \
'if col -bp < "$log_file" | sed '"'"'s/\x1b\[[0-9;?]*[a-zA-Z]//g; /^Script \(started\|done\)/d'"'"' > "${log_file}.tmp" 2>/dev/null; then' \
' mv "${log_file}.tmp" "$log_file"' \
'else' \
' rm -f "${log_file}.tmp"' \
'fi' \
'' \
'max_files="${SCROLLBACK_HISTORY_MAX_FILES:-100}"' \
'mapfile -t logs < <(ls -1t "$log_dir"/paru_*.log 2>/dev/null)' \
+7 -3
View File
@@ -20,7 +20,7 @@ end
set -l _yay_real /usr/bin/yay
set -l _yay_wrapper "$HOME/.local/bin/yay"
set -l _yay_wrapper_version 2
set -l _yay_wrapper_version 3
# Skip entirely if the real yay binary isn't present
test -x $_yay_real; or return
@@ -54,8 +54,12 @@ printf '%s\n' \
'script -q -e -c "$cmd_str" "$log_file"' \
'exit_code=$?' \
'' \
'# Strip ANSI escape sequences and carriage returns for readable plain-text logs.' \
'sed -i '"'"'s/\x1b\[[0-9;?]*[a-zA-Z]//g; s/\r//g'"'"' "$log_file" 2>/dev/null || true' \
'# col -bp collapses CR-redrawn progress bar frames; sed strips ANSI codes and script(1) headers.' \
'if col -bp < "$log_file" | sed '"'"'s/\x1b\[[0-9;?]*[a-zA-Z]//g; /^Script \(started\|done\)/d'"'"' > "${log_file}.tmp" 2>/dev/null; then' \
' mv "${log_file}.tmp" "$log_file"' \
'else' \
' rm -f "${log_file}.tmp"' \
'fi' \
'' \
'max_files="${SCROLLBACK_HISTORY_MAX_FILES:-100}"' \
'mapfile -t logs < <(ls -1t "$log_dir"/yay_*.log 2>/dev/null)' \