From 5577178eeb0acf26def7d0709ec6996255b76992 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 19 Oct 2025 17:32:25 +0200 Subject: [PATCH] fix: Only display non-zero percentage (#1087) --- src/progress.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/progress.sh b/src/progress.sh index 8080156..24d0e8f 100644 --- a/src/progress.sh +++ b/src/progress.sh @@ -21,27 +21,23 @@ if [[ "$body" == *"..." ]]; then body="

${body::-3}

" fi -cluster=$(stat -f "$path" | grep -m 1 "^Block size:" | cut -d':' -f2 | tail -c+2 | cut -d' ' -f1) -total=$(( ( ( total + cluster / 2 ) / cluster ) * cluster )) -[ -z "$total" ] && total="4096" - while true do if [ ! -s "$path" ] && [ ! -d "$path" ]; then bytes="0" else - bytes=$(du -sB 1 "$path" | cut -f1) + bytes=$(du -sb "$path" | cut -f1) fi - if (( bytes > cluster )); then + if (( bytes > 4096 )); then if [ -z "$total" ] || [[ "$total" == "0" ]] || [ "$bytes" -gt "$total" ]; then size=$(numfmt --to=iec --suffix=B "$bytes" | sed -r 's/([A-Z])/ \1/') else size="$(echo "$bytes" "$total" | awk '{printf "%.1f", $1 * 100 / $2}')" size="$size%" fi - echo "${body//(\[P\])/($size)}"> "$info" + [[ "$size" != "0.0%" ]] && echo "${body//(\[P\])/($size)}"> "$info" fi sleep 1 & wait $!