Skip to content

Fix uninstall fails with unbound variable on empty passthru array - #1

Open
thalissonbarbosas wants to merge 1 commit into
0xrafasec:mainfrom
thalissonbarbosas:fix/empty-passthru-array
Open

Fix uninstall fails with unbound variable on empty passthru array#1
thalissonbarbosas wants to merge 1 commit into
0xrafasec:mainfrom
thalissonbarbosas:fix/empty-passthru-array

Conversation

@thalissonbarbosas

Copy link
Copy Markdown

Summary

  • aiwf uninstall (and uninstall-all) crashes on macOS with passthru[@]: unbound variable
  • Root cause: bash 3.x (macOS default) raises unbound variable under set -u when expanding an empty array as "${passthru[@]}"
  • Fix: use "${passthru[@]+"${passthru[@]}"}" — the ${var+alt} form that expands to nothing when the array is empty

The Problem

cmd_uninstall initialises local passthru=() and then calls:

"$INSTALL_DIR/uninstall.sh" "${passthru[@]}"

With set -euo pipefail at the top of the script, the -u flag causes bash 3.2 (the version shipped with macOS) to treat an empty-array expansion as an unbound variable and abort.

What's Changed

# before
"$INSTALL_DIR/uninstall.sh" "${passthru[@]}"

# after
"$INSTALL_DIR/uninstall.sh" "${passthru[@]+"${passthru[@]}"}"

The ${var+alternate} form only expands when the variable/array is set and non-empty — the standard bash idiom for safely passing optional array arguments under set -u.

Test Plan

  • aiwf uninstall runs without error when no extra flags are passed
  • aiwf uninstall --purge still forwards --purge correctly to uninstall.sh
  • aiwf uninstall-all completes successfully

🤖 Generated with Claude Code

Under bash set -u, expanding an empty array as ${passthru[@]} raises
'unbound variable' on bash 3.x (macOS default). Use the ${var+alt} form
to expand only when non-empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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