diff --git a/lib/reference-db.sh b/lib/reference-db.sh index e7ab327..6c70d33 100755 --- a/lib/reference-db.sh +++ b/lib/reference-db.sh @@ -173,11 +173,13 @@ build_users_section() { # Get all domains once and reuse (avoid duplicate function calls) local user_all_domains=$(get_user_domains "$user") local primary_domain=$(echo "$user_all_domains" | head -1) - local domain_count=$(echo "$user_all_domains" | grep -v "^$" | wc -l) - local db_count=$(get_user_databases "$user" | grep -v "^$" | wc -l) + # Use || echo 0 to handle grep failure with set -eo pipefail (when no domains exist) + local domain_count=$(echo "$user_all_domains" | grep -v "^$" | wc -l || echo 0) + local db_count=$(get_user_databases "$user" | grep -v "^$" | wc -l || echo 0) # Get disk usage (quick du) - local home_dir=$(get_user_info "$user" | grep "^HOME_DIR=" | cut -d= -f2) + # Use || echo "" to handle grep failure with set -eo pipefail + local home_dir=$(get_user_info "$user" | grep "^HOME_DIR=" | cut -d= -f2 || echo "") local disk_mb=0 if [ -n "$home_dir" ] && [ -d "$home_dir" ]; then disk_mb=$(du -sm "$home_dir" 2>/dev/null | awk '{print $1}')