Skip to content

fix(hooks): bash-3.2-compatible pre-commit (replace mapfile with read_nul_array) - #23

Merged
supmo668 merged 1 commit into
mainfrom
mangyinm/fix-precommit-bash32
Jun 17, 2026
Merged

supmo668 merged 1 commit into
mainfrom
mangyinm/fix-precommit-bash32

Conversation

@supmo668

@supmo668 supmo668 commented Jun 17, 2026 •

Copy link
Copy Markdown

What

git-hooks/pre-commit used mapfile -d '' (bash 4+), but macOS default /bin/bash is 3.2 → hook broke, forcing --no-verify commits. Adds a read_nul_array helper (read -r -d '' loop in the current shell via process substitution) replacing all three mapfile calls; preserves NUL-delimited handling (spaces/newlines) + option-injection safety.

Verification (openclaw agent + CTO review)

  • Committed WITHOUT --no-verify → the fixed hook ran clean on /bin/bash 3.2.57.
  • CTO code-review PASS: 1 file, correct bash-3.2 pattern, safety preserved.

Tooling/hook fix (no QGR receipt needed — code-review + clean-run is the gate). Unblocks everyone on bash 3.2 from --no-verify. Authored by openclaw, landed by CTO.

Summary by CodeRabbit

  • Chores
    • Updated internal pre-commit hook to improve file handling robustness.

mapfile/readarray are bash 4+ builtins; macOS ships bash 3.2 as /bin/bash, so
the hook aborted with 'mapfile: command not found' and every commit needed
--no-verify. Replace the three mapfile -d '' calls with a read_nul_array helper
(a bash-3.2 'read -r -d ' loop in the current shell via process substitution),
preserving NUL-delimited handling of spaces/newlines and the option-injection
safety. Verified on /bin/bash 3.2.57.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@supmo668
supmo668 merged commit 7d138d0 into main Jun 17, 2026
@supmo668
supmo668 deleted the mangyinm/fix-precommit-bash32 branch June 17, 2026 23:41
@github-actions

Copy link
Copy Markdown

⚠️ Formal models conformance drift detected

The formal models extracted constants (generated/*) do not match this openclaw PR.

This check is informational (not blocking merges yet).
See the formal-models-conformance-drift artifact for the diff.

If this change is intentional, follow up by updating the formal models repo or regenerating the extracted artifacts there.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 07bced03-b279-4daf-8640-9c5ff591faa1

📥 Commits

Reviewing files that changed from the base of the PR and between 51562b7 and c4b5e3f.

📒 Files selected for processing (1)
  • git-hooks/pre-commit

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

The pre-commit hook replaces mapfile -d '' array population with a new read_nul_array bash function that uses read -d '' and eval with process substitution, restoring compatibility with bash 3.2. The files, lint_files, and format_files arrays are now populated via this helper.

Changes

Bash 3.2-compatible NUL array population

Layer / File(s) Summary
read_nul_array helper and array wiring
git-hooks/pre-commit
Adds read_nul_array() which reads a NUL-delimited stream into a named array using read -d '' and eval inside process substitution (bash 3.2 safe). Replaces mapfile -d '' -t calls for files, lint_files, and format_files.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppy news from the warren today,
mapfile was sent on its way!
With read -d '' and an eval in hand,
bash 3.2 can now understand.
NUL-delimited files, hop into your place —
the pre-commit hook runs at a snappier pace! 🌿

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mangyinm/fix-precommit-bash32

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant