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 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 21:59:36 +02:00
parent 040f861096
commit 19f6077e33

View File

@@ -4,14 +4,15 @@
[[ -n "${_GNIZA4LINUX_SNAPLOG_LOADED:-}" ]] && return 0 [[ -n "${_GNIZA4LINUX_SNAPLOG_LOADED:-}" ]] && return 0
_GNIZA4LINUX_SNAPLOG_LOADED=1 _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 # 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() { _snaplog_tee() {
while IFS= read -r line; do if [[ -n "${LOG_FILE:-}" ]]; then
echo "$line" >> "${_TRANSFER_LOG}" tee -a "${_TRANSFER_LOG}" "${LOG_FILE}" >&2
[[ -n "${LOG_FILE:-}" ]] && echo "$line" >> "${LOG_FILE}" else
echo "$line" >&2 tee -a "${_TRANSFER_LOG}" >&2
done fi
} }
# Initialize snapshot log directory and transfer log file. # Initialize snapshot log directory and transfer log file.