common: finish the copy bar at 100%

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-17 09:51:40 +01:00
parent f4c6e2238a
commit d4b76f2b13

View file

@ -29,6 +29,7 @@ let
{
blocks='########################################'
drawn=
total=0
while read -r tag rest; do
case "$tag" in
A) copy_id=$rest ;;
@ -36,6 +37,7 @@ let
printf '%s\n' "$rest" >&2 ;;
P) set -- $rest
[ "$1" = "''${copy_id:-}" ] && [ "''${3:-0}" -gt 0 ] || continue
total=$3
pct=$(( $2 * 100 / $3 ))
printf '\r[%-40s] %3d%% %d/%d paths' \
"''${blocks:0:$(( pct * 40 / 100 ))}" "$pct" "$2" "$3"
@ -45,7 +47,14 @@ let
# `if`, not `[ … ] && …`: with nothing to copy the bar never draws, and a
# bare test as the last statement would exit 1 and break the caller's
# && chain. A real copy failure still surfaces via the caller's pipefail.
if [ -n "$drawn" ]; then printf '\n'; fi
#
# nix stops emitting type-105 results once the last path lands, so the
# bar's last live frame is always one path short. Redraw it full on EOF.
# An error would have cleared $drawn via the M branch first, so this only
# fires on a copy that actually finished.
if [ -n "$drawn" ]; then
printf '\r[%-40s] 100%% %d/%d paths\n' "$blocks" "$total" "$total"
fi
}
'';