From d4b76f2b13072d4d87d7d67b22e262b72ab692ef Mon Sep 17 00:00:00 2001 From: rope Date: Mon, 17 Aug 2026 09:51:40 +0100 Subject: [PATCH] common: finish the copy bar at 100% Co-Authored-By: Claude Opus 5 --- common.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common.nix b/common.nix index 57e74b9..8d5ef40 100644 --- a/common.nix +++ b/common.nix @@ -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 } '';