From 19f6077e33e9ea6c634118013aa50410bb52ac09 Mon Sep 17 00:00:00 2001 From: shuki Date: Fri, 6 Mar 2026 21:59:36 +0200 Subject: [PATCH] Fix progress stuck: use tee instead of read-line in _snaplog_tee The old read -r line approach buffered until \n, but rsync --info=progress2 uses \r without \n for progress updates. Using tee(1) preserves \r characters and writes through immediately for real-time progress. Co-Authored-By: Claude Opus 4.6 --- lib/snaplog.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/snaplog.sh b/lib/snaplog.sh index cc5b5b6..501d395 100644 --- a/lib/snaplog.sh +++ b/lib/snaplog.sh @@ -4,14 +4,15 @@ [[ -n "${_GNIZA4LINUX_SNAPLOG_LOADED:-}" ]] && return 0 _GNIZA4LINUX_SNAPLOG_LOADED=1 -# Tee helper: writes each line to the transfer log, app log, and stderr (TUI). +# Tee helper: copies stdin to the transfer log, app log, and stderr (TUI). # Used as process substitution target: cmd > >(_snaplog_tee) 2>&1 +# Uses tee(1) to preserve \r from rsync --info=progress2 in real-time. _snaplog_tee() { - while IFS= read -r line; do - echo "$line" >> "${_TRANSFER_LOG}" - [[ -n "${LOG_FILE:-}" ]] && echo "$line" >> "${LOG_FILE}" - echo "$line" >&2 - done + if [[ -n "${LOG_FILE:-}" ]]; then + tee -a "${_TRANSFER_LOG}" "${LOG_FILE}" >&2 + else + tee -a "${_TRANSFER_LOG}" >&2 + fi } # Initialize snapshot log directory and transfer log file.