Skip to content

check.sh: fix unbound SAMPLE array on bash 3.2 (macOS) - #10

Merged
ilien-dev merged 1 commit into
ilien-dev:mainfrom
CavaTrendy:fix/bash32-empty-sample-array
Nov 13, 2026
Merged

ilien-dev merged 1 commit into
ilien-dev:mainfrom
CavaTrendy:fix/bash32-empty-sample-array

Conversation

@CavaTrendy

Copy link
Copy Markdown
Contributor

Problem

On macOS the default /bin/bash is 3.2. With set -u, bash 3.2 treats "${SAMPLE[@]}" on an empty array as an unbound variable, so any check.sh run without --sample fails:

=== rates
scripts/check.sh: line 39: SAMPLE[@]: unbound variable

=== checklist
scripts/check.sh: line 42: SAMPLE[@]: unbound variable

The run never produces the rates or the checklist, so the loop can't converge.

Fix

Use ${SAMPLE[@]+"${SAMPLE[@]}"} on lines 39 and 42. It expands to nothing when the array is empty and to the quoted elements otherwise. It works on bash 3.2 and on 4+. The SOURCE array was already guarded by its ${#SOURCE[@]} -gt 0 check.

Tested

With GNU bash, version 3.2.57(1)-release (arm64-apple-darwin), running check.sh FILE --ruled x without --sample:

  • before the fix: the two unbound variable errors above
  • after the fix: the full rates and checklist output, then CLEAN PASS 1 of 2, ruled.

🤖 Generated with Claude Code

With set -u, bash 3.2 treats "${SAMPLE[@]}" on an empty array as an
unbound variable, so every run without --sample aborts the rates and
checklist steps. Use ${SAMPLE[@]+"${SAMPLE[@]}"}, which expands to
nothing when the array is empty and is safe on all bash versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ilien-dev
ilien-dev merged commit 603ff08 into ilien-dev:main Nov 13, 2026
@ilien-dev

Copy link
Copy Markdown
Owner

Thanks you so much! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants