Repository navigation
check.sh: fix unbound SAMPLE array on bash 3.2 (macOS) - #10
Merged
ilien-dev merged 1 commit intoNov 13, 2026
Merged
Conversation
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>
Owner
|
Thanks you so much! :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS the default
/bin/bashis 3.2. Withset -u, bash 3.2 treats"${SAMPLE[@]}"on an empty array as an unbound variable, so anycheck.shrun without--samplefails: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+. TheSOURCEarray was already guarded by its${#SOURCE[@]} -gt 0check.Tested
With
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin), runningcheck.sh FILE --ruled xwithout--sample:unbound variableerrors aboveCLEAN PASS 1 of 2, ruled.🤖 Generated with Claude Code