Skip to content

fix: lang install bash-3.2 crash + mirror block to AGENTS.md - #38

Merged
zywkloo merged 1 commit into
mainfrom
fix/lang-bash32-agents-md
Jun 24, 2026
Merged

fix: lang install bash-3.2 crash + mirror block to AGENTS.md#38
zywkloo merged 1 commit into
mainfrom
fix/lang-bash32-agents-md

Conversation

@zywkloo

@zywkloo zywkloo commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Crash fix: wtc lang install with no extra positional args crashed on macOS bash 3.2 (remaining[@]: unbound variable) due to empty-array expansion under set -u. Fixed with the bash-3.2-safe idiom ${arr[@]+"${arr[@]}"}.
  • AGENTS.md support: lang install/remove now mirrors the block to AGENTS.md when it exists, matching how wtcraft patch/unpatch treats agent files. If neither CLAUDE.md nor AGENTS.md exists, exits 1 and points user at wtcraft patch.
  • Test suite fix: replaced bash-4-only mapfile with while IFS= read -r in tests/unit_awk.sh — the suite was silently bailing on macOS bash 3.2 before hitting any real tests.
  • Regression test: new tests/e2e_lang.sh covers all four cases (CLAUDE.md-only, AGENTS.md-only, both, neither) and would have caught the original crash automatically.

Root cause

macOS ships bash 3.2 (frozen since 2007 for GPLv3 reasons). In bash 3.2, "${empty_array[@]}" under set -u is treated as an unbound variable and errors. In bash 4.4+ it quietly produces zero args. CI runs on Ubuntu (bash 5) so this was green in CI and crashing on every Mac.

Test plan

  • bash tests/e2e_lang.sh — all 5 cases pass
  • bash tests/unit_awk.sh — passes on macOS bash 3.2 (no more mapfile crash)
  • wtc lang install in a repo with only CLAUDE.md — patches CLAUDE.md, no AGENTS.md created
  • wtc lang install in a repo with both files — patches both
  • wtc lang install in an empty git repo — exits 1, mentions wtcraft patch

Empty-array expansion under set -u caused 'remaining[@]: unbound
variable' on macOS bash 3.2 when no extra args were passed to
wtc lang install. Fixed with the bash-3.2-safe idiom.

lang install/remove now mirrors the block to AGENTS.md when it
exists, matching how wtcraft patch/unpatch treats agent files.
If neither CLAUDE.md nor AGENTS.md exists, the command exits 1
and points the user at 'wtcraft patch'.

Also fixes mapfile in tests/unit_awk.sh (bash 4+ only) so the
test suite can run on macOS bash 3.2, and adds e2e_lang.sh to
cover all four cases (CLAUDE.md-only, AGENTS.md-only, both, neither).
@zywkloo
zywkloo merged commit 91e67e3 into main Jun 24, 2026
1 check passed
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