From 5c32e2cb13f6aa2b84188bec740003d83ae5cccb Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 31 Aug 2026 11:29:27 +0200 Subject: [PATCH 1/2] fix(scripts): make check-authors work on macOS bash 3.2 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) Signed-off-by: Marc Nuri --- scripts/check-authors.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/scripts/check-authors.sh b/scripts/check-authors.sh index 7769ef23..9831d36e 100755 --- a/scripts/check-authors.sh +++ b/scripts/check-authors.sh @@ -68,22 +68,24 @@ fi # Build list of known authors from all @author tags in the codebase echo "Building list of known authors from codebase..." -declare -A KNOWN_AUTHORS +KNOWN_AUTHORS=() while IFS= read -r author; do if [[ -n "$author" ]]; then - KNOWN_AUTHORS["$author"]=1 + KNOWN_AUTHORS+=("$author") fi -done < <(grep -rhoP '@author\s+\K.+' --include="*.java" . 2>/dev/null | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sort -u) +done < <(find . -name "*.java" -type f ! -path "*/target/*" \ + -exec sed -n 's/.*@author[[:space:]][[:space:]]*//p' {} + \ + | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sort -u) if [[ "$VERBOSE" == true ]]; then - echo "Known authors: ${!KNOWN_AUTHORS[*]}" + echo "Known authors: ${KNOWN_AUTHORS[*]+"${KNOWN_AUTHORS[*]}"}" fi echo "" # Extract @author tags from a Java file get_javadoc_authors() { local file="$1" - grep -oP '@author\s+\K.+' "$file" 2>/dev/null | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' || true + sed -n 's/.*@author[[:space:]][[:space:]]*//p' "$file" 2>/dev/null | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' || true } # Get git contributors for a file @@ -112,7 +114,7 @@ MISSING_AUTHORS_TOTAL=0 echo "Checking Java files for author information..." echo "" -for file in "${FILES[@]}"; do +for file in "${FILES[@]+"${FILES[@]}"}"; do if [[ ! -f "$file" ]]; then continue fi @@ -120,15 +122,25 @@ for file in "${FILES[@]}"; do ((TOTAL_FILES++)) || true # Get authors from JavaDoc - readarray -t javadoc_authors < <(get_javadoc_authors "$file") + javadoc_authors=() + while IFS= read -r author; do + if [[ -n "$author" ]]; then + javadoc_authors+=("$author") + fi + done < <(get_javadoc_authors "$file") # Get authors from git history - readarray -t git_authors < <(get_git_authors "$file") + git_authors=() + while IFS= read -r author; do + if [[ -n "$author" ]]; then + git_authors+=("$author") + fi + done < <(get_git_authors "$file") # Filter to only known authors (ignore unknown git usernames) known_git_authors=() - for author in "${git_authors[@]}"; do - if [[ -n "$author" ]] && [[ -v "KNOWN_AUTHORS[$author]" ]]; then + for author in "${git_authors[@]+"${git_authors[@]}"}"; do + if array_contains "$author" "${KNOWN_AUTHORS[@]+"${KNOWN_AUTHORS[@]}"}"; then if ! array_contains "$author" "${known_git_authors[@]+"${known_git_authors[@]}"}"; then known_git_authors+=("$author") fi From 3208620c118fc384615b0a233034723486eee6fb Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 31 Aug 2026 11:36:55 +0200 Subject: [PATCH 2/2] fix(scripts): restore stderr suppression on known-authors scan 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) Signed-off-by: Marc Nuri --- scripts/check-authors.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-authors.sh b/scripts/check-authors.sh index 9831d36e..207f9658 100755 --- a/scripts/check-authors.sh +++ b/scripts/check-authors.sh @@ -74,7 +74,7 @@ while IFS= read -r author; do KNOWN_AUTHORS+=("$author") fi done < <(find . -name "*.java" -type f ! -path "*/target/*" \ - -exec sed -n 's/.*@author[[:space:]][[:space:]]*//p' {} + \ + -exec sed -n 's/.*@author[[:space:]][[:space:]]*//p' {} + 2>/dev/null \ | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sort -u) if [[ "$VERBOSE" == true ]]; then