fix: setup.sh cross-shell grep -c arithmetic error#915
Conversation
grep -cE outputs '0' on no match (exit 1), then '|| echo 0' appends
a second '0' line, producing '0\n0' which breaks $(( )) arithmetic.
Fix: use '|| true' to suppress exit code without appending output,
and ${n:-0} as safety fallback for empty values.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Tue Feb 10 04:25:00 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
setup.sh (2)
2688-2689:⚠️ Potential issue | 🟡 MinorSame
grep -c ... || echo "0"bug exists here (unfixed).Line 2688 uses the identical pre-fix pattern that was just corrected in
setup_shell_compatibility(). Underset -euo pipefail, whengrep -cfinds no matches it prints"0"(exit 1), then|| echo "0"appends a second"0", producing"0\n0". The subsequent arithmetic comparison on line 2689 ([[ "$disabled_count" -gt 0 ]]) would fail with a non-numeric value.Proposed fix
- disabled_count=$(grep -c "disableDynamicTitle: true" "$tabby_config" 2>/dev/null || echo "0") - if [[ "$disabled_count" -gt 0 ]]; then + disabled_count=$(grep -c "disableDynamicTitle: true" "$tabby_config" 2>/dev/null) || true + if [[ "${disabled_count:-0}" -gt 0 ]]; then
4849-4849:⚠️ Potential issue | 🟡 MinorSame
grep -c ... || echo "0"bug exists here too (unfixed).Line 4849 has the identical pattern. While
key_countis only used in an informationalprint_infomessage (so the impact is cosmetic — the message would show"0\n0"instead of"0"), it's worth applying the same fix for consistency.Proposed fix
- key_count=$(grep -c "^export " "$HOME/.config/aidevops/credentials.sh" 2>/dev/null || echo "0") + key_count=$(grep -c "^export " "$HOME/.config/aidevops/credentials.sh" 2>/dev/null) || true



Summary
setup_shell_compatibility()at line ~1553 of setup.shgrep -cEoutputs0on no match (exit code 1), then|| echo "0"appends a second0line, producing"0\n0"which breaks$(( ))arithmetic|| trueto suppress exit code without appending output, and${n:-0}as safety fallbackRoot Cause
Impact
This bug was introduced by PR #900 and blocks all autonomous deploys via
run_deploy_for_task()in the supervisor. The error is non-fatal (setup.sh continues) but produces confusing output and may cause incorrect cross-shell compatibility detection.Testing
setup.sh --non-interactivecompletes with zero errorsSummary by CodeRabbit