Skip to content

fix(scripts): make check-authors work on macOS bash 3.2 - #423

Merged
manusa merged 2 commits into
mainfrom
fix/check-authors-macos
Aug 31, 2026
Merged

fix(scripts): make check-authors work on macOS bash 3.2#423
manusa merged 2 commits into
mainfrom
fix/check-authors-macos

Conversation

@manusa

@manusa manusa commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Problem

make check-authors aborts immediately on macOS:

./scripts/check-authors.sh: line 71: declare: -A: invalid option

macOS ships bash 3.2, and the script relied on four constructs that aren't
available there — the declare -A failure was just the first one hit.

Construct Requires macOS
declare -A KNOWN_AUTHORS bash 4.0+ bash 3.2
readarray bash 4.0+
[[ -v KNOWN_AUTHORS[$author] ]] bash 4.2+
grep -oP '@author\s+\K.+' GNU grep BSD grep rejects -P

Changes

  • Associative array → plain indexed array, reusing the script's existing
    array_contains helper (which also replaces the -v key test).
  • readarraywhile IFS= read -r loops.
  • grep -oP ... \K → POSIX sed -n 's/.*@author[[:space:]][[:space:]]*//p'.
  • Empty-array expansions now use the ${arr[@]+"${arr[@]}"} idiom the script
    already used elsewhere — bash 3.2 under set -u errors on "${empty[@]}".
  • The known-authors scan now excludes */target/*, matching the filter already
    used for file discovery, so results don't change depending on whether a build
    has run.

No behavioural change intended: the sed extraction was verified byte-identical
to the original PCRE version across every Java file in the repo.

Note

The script is a manual target (CI does not run it). Now that it executes on
macOS, it reports 10 pre-existing missing @author entries across 8 files.
Those are left untouched here — this PR only fixes the script.

The script aborted immediately on macOS with "declare: -A: invalid
option". It relied on four constructs unavailable there: associative
arrays and readarray (bash 4.0+), the -v array-key test (bash 4.2+),
and grep -oP with \K (GNU grep; /usr/bin/grep rejects -P).

Replaces them with an indexed array plus the script's existing
array_contains helper, while-read loops, and a POSIX sed expression.
Empty-array expansions now use the ${arr[@]+...} idiom already used
elsewhere, since bash 3.2 under `set -u` errors on "${empty[@]}".

The known-authors scan also excludes */target/* so it matches the
file-discovery filter and is unaffected by whether a build has run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marc Nuri <marc@marcnuri.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The known-authors scan no longer suppresses stderr, which can introduce user-visible behavioral differences versus the prior 2>/dev/null behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates scripts/check-authors.sh to run correctly on macOS’s default Bash 3.2 by removing Bash 4+/GNU grep dependencies, keeping make check-authors usable for contributors on macOS.

Changes:

  • Replaces Bash 4 associative array usage and [[ -v ... ]] membership checks with plain arrays + an existing array_contains helper.
  • Replaces readarray with while IFS= read -r loops for Bash 3.2 compatibility.
  • Replaces GNU grep -P extraction with a portable sed -n extraction.
File summaries
File Description
scripts/check-authors.sh Makes the author-checking script compatible with macOS Bash 3.2 by removing Bash 4+/GNU grep-only constructs.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/check-authors.sh
The rewrite dropped the `2>/dev/null` the original grep had, so
unreadable files or transient errors would leak onto the terminal
mid-run. Restores it on the find invocation, which also covers the
-exec'd sed since children inherit find's stderr.

Matches the suppression already used by get_javadoc_authors and
get_git_authors.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marc Nuri <marc@marcnuri.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are localized to the script, remove Bash 4+/GNU grep dependencies as intended, and I didn’t find any functional regressions in the updated parsing/loops.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@manusa
manusa merged commit af56650 into main Aug 31, 2026
4 checks passed
@manusa
manusa deleted the fix/check-authors-macos branch August 31, 2026 10:42
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