Skip to content

Fix mapfile for macOS default bash 3.2 (sync.sh, pull.sh) - #1

Open
jackiexi1986-AI wants to merge 1 commit into
bradvin:mainfrom
jackiexi1986-AI:fix-mapfile-bash32
Open

jackiexi1986-AI wants to merge 1 commit into
bradvin:mainfrom
jackiexi1986-AI:fix-mapfile-bash32

Conversation

@jackiexi1986-AI

Copy link
Copy Markdown

Problem

On macOS the default /bin/bash is 3.2 (3.2.57), which does not ship the mapfile/readarray builtin (bash 4+). Three call sites used mapfile -t ... < <(jq ...):

  • scripts/sync.sh — jq branch, two places (group_names, paths). The script died with mapfile: command not found (exit 127) right before the grouped commits, so the sync never reached git push.
  • scripts/pull.sh — one place (agent_rows, same jq + @tsv pattern). Identical failure when pulling per-agent rows.

bash -n does not catch this (it is a runtime missing-builtin, not a syntax error), and since scripts declare #!/usr/bin/env bash, on stock macOS they always run under bash 3.2.

Fix

Replace every mapfile -t arr < <(cmd) with the bash 3.2-compatible idiom:

arr=()
while IFS= read -r item; do arr+=("$item"); done < <(cmd)

Process substitution and while read both exist in bash 3.2, so behavior is unchanged on bash 4+/5.

Verification (macOS stock bash 3.2.57)

  • /bin/bash -n scripts/sync.sh scripts/pull.sh scripts/nightly_sync.sh — clean.
  • Full sync.sh chain against a scratch workspace + local bare remote: secret scan passed, per-group commits (core/skills/memory) plus the misc catch-all commit created and pushed — exit 0.
  • scripts/nightly_sync.sh end-to-end against a real remote: export → secret scan → commit → git push -u origin main — exit 0.

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