fix: lang install bash-3.2 crash + mirror block to AGENTS.md - #38
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
wtc lang installwith no extra positional args crashed on macOS bash 3.2 (remaining[@]: unbound variable) due to empty-array expansion underset -u. Fixed with the bash-3.2-safe idiom${arr[@]+"${arr[@]}"}.lang install/removenow mirrors the block toAGENTS.mdwhen it exists, matching howwtcraft patch/unpatchtreats agent files. If neitherCLAUDE.mdnorAGENTS.mdexists, exits 1 and points user atwtcraft patch.mapfilewithwhile IFS= read -rintests/unit_awk.sh— the suite was silently bailing on macOS bash 3.2 before hitting any real tests.tests/e2e_lang.shcovers 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[@]}"underset -uis 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 passbash tests/unit_awk.sh— passes on macOS bash 3.2 (no moremapfilecrash)wtc lang installin a repo with onlyCLAUDE.md— patches CLAUDE.md, no AGENTS.md createdwtc lang installin a repo with both files — patches bothwtc lang installin an empty git repo — exits 1, mentionswtcraft patch