refactor(shell): use [[ ]] for conditional tests in scripts/compliance-audit.sh (S7688, part of #1462)

Merged
DO
6d ago
+194-194

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.

SplitScope
Ascripts/canary-rollout.sh + tests/canary_rollout.bats
Bscripts/compliance-audit.sh
Cother top-level scripts/*.sh + their tests
Dscripts/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 0 instead of failing the test;
  • a leading-zero value is read as octal (08 is an error, 010 is 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 run cmd.

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/sh script.
  • shellcheck -x -S warning reports no new findings compared with main.
  • Related bats suites, run locally on this branch (GNU date, bash 5), with any failure re-run on main: 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.