Skip to content

fix: Handle empty array binding in Bash 3.x in MacOS#2

Closed
abhisek wants to merge 2 commits into
cyfinoid:mainfrom
abhisek:fix/empty-array-unbound-var-bash32
Closed

fix: Handle empty array binding in Bash 3.x in MacOS#2
abhisek wants to merge 2 commits into
cyfinoid:mainfrom
abhisek:fix/empty-array-unbound-var-bash32

Conversation

@abhisek

@abhisek abhisek commented Jun 24, 2026

Copy link
Copy Markdown

The bug

./install.sh failed on macOS with:

lib/aidc.sh: line 1865: desired_aliases[@]: unbound variable

A fresh install has no Claude profiles yet, so the alias list is empty. macOS still ships bash 3.2, where expanding an empty array as "${arr[@]}" under set -u is treated as an unbound variable and aborts. Bash 4+ (so Linux) doesn't do this, which is why it only bit Mac users — on the very first command they run.

The fix

Guard every dynamically-built array that can legitimately be empty with "${arr[@]+"${arr[@]}"}", which expands to nothing when empty instead of erroring. The duplicated compose … exec call is folded into one aidc::compose_exec helper so the guard lives in a single place. Arrays that are never empty are left as-is, so the guard now reads as "this one can be empty."

Tests

New aidc-e2e.yml exercises the install and common CLI paths on both Ubuntu and macOS runners. The macOS leg is pinned to the system bash 3.2 (and asserts it took effect), so this can't quietly regress.

@anantshri

Copy link
Copy Markdown
Contributor

merged with #1

@anantshri anantshri closed this Jun 25, 2026
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.

2 participants