refactor(shell): use [[ ]] for conditional tests in scripts/compliance-audit.sh (S7688, part of #1462)
What
Split B of 5 of #1463, split by directory at the Maintainer's direction: scripts/compliance-audit.sh (1 files). It is part of #1462, SonarCloud shell:S7688: use [[ instead of [.
The files are taken unchanged from #1463 head 3c6d334, which was level with main. That PR's review rounds (CodeRabbit, Codex, pr-review) are already folded in. #1463 is closed in favour of these five smaller PRs, because a 68-file mechanical change kept drawing review rounds and never converged.
| Split | Scope |
|---|---|
| A | scripts/canary-rollout.sh + tests/canary_rollout.bats |
| B | scripts/compliance-audit.sh |
| C | other top-level scripts/*.sh + their tests |
| D | scripts/lib/*.sh + their tests |
| E | .github/scripts/** |
#1462 stays open until all five merge.
Review focus
Inside [[ ]], -eq/-ne/-lt/-le/-gt/-ge evaluate both operands as arithmetic, which [ ] does not:
- an empty or non-numeric operand now compares as
0instead of failing the test; - a leading-zero value is read as octal (
08is an error,010is 8). #1463 added$((10#ā¦))normalisation and tests where it found config values; - a value from outside (API JSON, issue text, env input) that reaches such a comparison unvalidated is evaluated, and a string like
a[$(cmd)]would runcmd.
Please check each numeric comparison in this diff whose operand is not a local counter or exit status.
Checks
- Every changed file passes
bash -n(bash 5) and is not a#!/bin/shscript. shellcheck -x -S warningreports no new findings compared withmain.- Related bats suites, run locally on this branch (GNU
date, bash 5), with any failure re-run onmain: compliance-audit suites (27 files) ā 361 ok, 0 failed.
š¤ Generated with Claude Code
Problem
See the linked issue.
Risk
Low ā changes automation shell logic under scripts/, covered by shellcheck (--severity=warning) and the bats suite.
Test plan
No test files were added or updated. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the existing CI (bats + lint) guards the change.
Rollback
Revert this PR. No non-revertible side effects (no tags, migrations, or external state).
Monitoring
This PR's Lint (shellcheck) and bats checks show pass/fail; watch subsequent dev-lead / pr-review runs for behavioral regressions.