Skip to content

Business operating system for Claude Code — 57 skills, 21 agents, smart daemon. Unified inbox (WhatsApp/Email/Slack/Telegram), autonomous PR merge, full-AWS monitoring, revenue (Stripe+RevenueCat), e-commerce (Shopify), marketing (Klaviyo/Meta/GA4), voice (Bland/ElevenLabs), APM (Datadog/NewRelic/OTEL), YOLO mode.

fix(ops-speedup): stop reporting a perfect score from no data on bash 3.2 (#827)

Aurora Capital6ce7baa06e33
diff --git a/claude-ops/bin/ops-speedup b/claude-ops/bin/ops-speedup
index f6e1028c..ad8643e8 100755
--- a/claude-ops/bin/ops-speedup
+++ b/claude-ops/bin/ops-speedup
@@ -459,37 +459,37 @@ run_parallel_scan() {
# Load disk vars — key must be alphanumeric+underscore to prevent injection
while IFS='=' read -r k v; do
[[ "$k" =~ ^[a-zA-Z0-9_]+$ ]] || continue
- declare -g "DISK_${k}=${v}"
+ eval "DISK_${k}=\$v"
done < "$tmp/disk" 2>/dev/null || true
# Load memory vars
while IFS='=' read -r k v; do
[[ "$k" =~ ^[a-zA-Z0-9_]+$ ]] || continue
- declare -g "MEM_${k}=${v}"
+ eval "MEM_${k}=\$v"
done < "$tmp/mem" 2>/dev/null || true
# Load network vars
while IFS='=' read -r k v; do
[[ "$k" =~ ^[a-zA-Z0-9_]+$ ]] || continue
- declare -g "NET_${k}=${v}"
+ eval "NET_${k}=\$v"
done < "$tmp/net" 2>/dev/null || true
# Load startup vars
while IFS='=' read -r k v; do
[[ "$k" =~ ^[a-zA-Z0-9_]+$ ]] || continue
- declare -g "STARTUP_${k}=${v}"
+ eval "STARTUP_${k}=\$v"
done < "$tmp/startup" 2>/dev/null || true
# Load runtime vars
while IFS='=' read -r k v; do
[[ "$k" =~ ^[a-zA-Z0-9_]+$ ]] || continue
- declare -g "RUNTIME_${k}=${v}"
+ eval "RUNTIME_${k}=\$v"
done < "$tmp/runtime" 2>/dev/null || true
# Load GPU vars
while IFS='=' read -r k v; do
[[ "$k" =~ ^[a-zA-Z0-9_]+$ ]] || continue
- declare -g "GPU_${k}=${v}"
+ eval "GPU_${k}=\$v"
done < "$tmp/gpu" 2>/dev/null || true
# Persist scan data; update file vars to the persistent copy so action
diff --git a/claude-ops/tests/test-ops-speedup.sh b/claude-ops/tests/test-ops-speedup.sh
index 112e9c1d..08b43c47 100644
--- a/claude-ops/tests/test-ops-speedup.sh
+++ b/claude-ops/tests/test-ops-speedup.sh
@@ -95,6 +95,42 @@ print("json-contract-ok")
PY
)"
+# Portability: macOS ships bash 3.2 as /bin/bash, and `#!/usr/bin/env bash`
+# resolves to it whenever /usr/bin precedes a newer bash on PATH — which is the
+# default for login shells, launchd, and cron. `declare -g` does not exist in
+# 3.2, so using it to publish probe results silently left every RUNTIME_/MEM_/
+# NET_/DISK_/STARTUP_/GPU_ variable unset and scored a perfect 100 from no data.
+# Keep the assignments portable; the loops below redirect stderr, so a 4-only
+# builtin fails invisibly rather than erroring out.
+assert_true "no bash-4-only declare -g" bash -c "! grep -q 'declare -g' '$BIN'"
+
+# The probe read-back must actually populate globals. Process count is the
+# cheapest environment-independent witness: any live host has processes, so a
+# zero here means the probe variables never made it back into scope.
+assert_eq "probe vars reach global scope" "populated" "$(python3 - "$json_out" <<'PY'
+import json, sys
+data = json.loads(sys.argv[1])
+procs = int(data["runtime"].get("processes") or 0)
+print("populated" if procs > 0 else f"empty:processes={procs}")
+PY
+)"
+
+# Run the same contract under the host's /bin/bash when that is a 3.x build.
+# Without this the suite only ever exercises the newer bash on PATH and cannot
+# catch a 4-only builtin regressing the macOS default interpreter.
+legacy_bash_version=$(/bin/bash -c 'echo "${BASH_VERSINFO[0]}"' 2>/dev/null || echo "")
+if [ "$legacy_bash_version" = "3" ]; then
+ assert_eq "populates probe vars under /bin/bash 3.x" "populated" "$(python3 - "$(/bin/bash "$BIN" --json)" <<'PY'
+import json, sys
+data = json.loads(sys.argv[1])
+procs = int(data["runtime"].get("processes") or 0)
+print("populated" if procs > 0 else f"empty:processes={procs}")
+PY
+)"
+else
+ pass "populates probe vars under /bin/bash 3.x (skipped: /bin/bash is ${legacy_bash_version:-unknown}.x)"
+fi
+
# Score contract: disk reclaimable size must not lower health, and launch-agent
# count must not either. Inject a synthetic runtime that is healthy except for
# large reclaimable numbers and many launch agents.