From 59b8db44ea44e3f24cb8989f9a6d3b46cb9937a7 Mon Sep 17 00:00:00 2001 From: cschantz Date: Wed, 19 Nov 2025 16:44:24 -0500 Subject: [PATCH] Fix division by zero in progress indicator - Add check for total=0 before calculating percentage - Prevents crash when indexing empty user/database lists - Displays 100% completion for empty lists --- lib/common-functions.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/common-functions.sh b/lib/common-functions.sh index db31f99..7f2952e 100755 --- a/lib/common-functions.sh +++ b/lib/common-functions.sh @@ -117,6 +117,13 @@ show_progress() { local current=$1 local total=$2 local message="$3" + + # Avoid division by zero + if [ "$total" -eq 0 ]; then + printf "\r[INFO] Progress: [####################] 100%% - %s" "$message" + return + fi + local percent=$((current * 100 / total)) local bars=$((percent / 5)) # 20 chars wide