From 4cd5f8ddb1bb662fa81cd0802ad269a06202485d Mon Sep 17 00:00:00 2001 From: cschantz Date: Wed, 3 Dec 2025 01:27:25 -0500 Subject: [PATCH] Fix arithmetic syntax error in analyze_all_domains Problem: - Line 220: syntax error in expression (error token is "0") - grep -c returns "0" on no match, but || echo "0" was still appending - Result: Variables contained "0\n0" causing arithmetic errors Fix: - Changed || echo "0" to || true - Added default value assignment: ${var:-0} - Ensures counts are always single integers Lines fixed: 215-224 --- modules/performance/php-optimizer.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/performance/php-optimizer.sh b/modules/performance/php-optimizer.sh index 83edf51..29dd805 100755 --- a/modules/performance/php-optimizer.sh +++ b/modules/performance/php-optimizer.sh @@ -212,10 +212,16 @@ analyze_all_domains() { # Count issues by severity local critical_count high_count medium_count low_count - critical_count=$(echo "$issues" | grep -c "^[^|]*|CRITICAL|" || echo "0") - high_count=$(echo "$issues" | grep -c "^[^|]*|HIGH|" || echo "0") - medium_count=$(echo "$issues" | grep -c "^[^|]*|MEDIUM|" || echo "0") - low_count=$(echo "$issues" | grep -c "^[^|]*|LOW|" || echo "0") + critical_count=$(echo "$issues" | grep -c "^[^|]*|CRITICAL|" || true) + high_count=$(echo "$issues" | grep -c "^[^|]*|HIGH|" || true) + medium_count=$(echo "$issues" | grep -c "^[^|]*|MEDIUM|" || true) + low_count=$(echo "$issues" | grep -c "^[^|]*|LOW|" || true) + + # Default to 0 if empty + critical_count=${critical_count:-0} + high_count=${high_count:-0} + medium_count=${medium_count:-0} + low_count=${low_count:-0} local total_issues=$((critical_count + high_count + medium_count + low_count))