Fix: Remove 'local' keyword from global scope (CRITICAL)

CRITICAL FIXES:
- Line 164: Remove 'local' from memory_reduction variable (global scope)
- Line 173: Remove 'local' from has_traffic variable (global scope)

Issue: 'local' keyword can only be used inside function definitions.
Using 'local' in global scope causes 'local: can only be used in a function'
runtime error and script failure.

RESULTS:
- 2 CRITICAL issues fixed
- Script now runs without global scope errors
This commit is contained in:
Developer
2026-03-20 01:26:45 -04:00
parent 50f5e2e378
commit 496dbf4f17
@@ -161,7 +161,7 @@ while IFS= read -r username; do
# Determine if optimization needed # Determine if optimization needed
# Flag as YES if: different from current (increase or decrease) # Flag as YES if: different from current (increase or decrease)
# AND has meaningful traffic (>= 5 concurrent) OR memory efficiency gain (> 20% reduction) # AND has meaningful traffic (>= 5 concurrent) OR memory efficiency gain (> 20% reduction)
local memory_reduction=0 memory_reduction=0
if [ "$recommended" -lt "$current" ]; then if [ "$recommended" -lt "$current" ]; then
memory_reduction=$(( (current - recommended) * 100 / current )) memory_reduction=$(( (current - recommended) * 100 / current ))
fi fi
@@ -170,7 +170,7 @@ while IFS= read -r username; do
# Check if change is meaningful: # Check if change is meaningful:
# 1. Has significant traffic (>= 5 concurrent requests) # 1. Has significant traffic (>= 5 concurrent requests)
# 2. OR significant memory reduction (>= 20%) # 2. OR significant memory reduction (>= 20%)
local has_traffic=0 has_traffic=0
[ "$peak" != "?" ] && [ "$peak" -ge 5 ] && has_traffic=1 [ "$peak" != "?" ] && [ "$peak" -ge 5 ] && has_traffic=1
if [ "$has_traffic" = "1" ] || [ "$memory_reduction" -ge 20 ]; then if [ "$has_traffic" = "1" ] || [ "$memory_reduction" -ge 20 ]; then