common: finish the copy bar at 100%
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f4c6e2238a
commit
d4b76f2b13
1 changed files with 10 additions and 1 deletions
11
common.nix
11
common.nix
|
|
@ -29,6 +29,7 @@ let
|
||||||
{
|
{
|
||||||
blocks='########################################'
|
blocks='########################################'
|
||||||
drawn=
|
drawn=
|
||||||
|
total=0
|
||||||
while read -r tag rest; do
|
while read -r tag rest; do
|
||||||
case "$tag" in
|
case "$tag" in
|
||||||
A) copy_id=$rest ;;
|
A) copy_id=$rest ;;
|
||||||
|
|
@ -36,6 +37,7 @@ let
|
||||||
printf '%s\n' "$rest" >&2 ;;
|
printf '%s\n' "$rest" >&2 ;;
|
||||||
P) set -- $rest
|
P) set -- $rest
|
||||||
[ "$1" = "''${copy_id:-}" ] && [ "''${3:-0}" -gt 0 ] || continue
|
[ "$1" = "''${copy_id:-}" ] && [ "''${3:-0}" -gt 0 ] || continue
|
||||||
|
total=$3
|
||||||
pct=$(( $2 * 100 / $3 ))
|
pct=$(( $2 * 100 / $3 ))
|
||||||
printf '\r[%-40s] %3d%% %d/%d paths' \
|
printf '\r[%-40s] %3d%% %d/%d paths' \
|
||||||
"''${blocks:0:$(( pct * 40 / 100 ))}" "$pct" "$2" "$3"
|
"''${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
|
# `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
|
# 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.
|
# && 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
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue