Fix uninstall fails with unbound variable on empty passthru array - #1
Open
thalissonbarbosas wants to merge 1 commit into
Open
Fix uninstall fails with unbound variable on empty passthru array#1thalissonbarbosas wants to merge 1 commit into
thalissonbarbosas wants to merge 1 commit into
Conversation
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>
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
aiwf uninstall(anduninstall-all) crashes on macOS withpassthru[@]: unbound variableunbound variableunderset -uwhen expanding an empty array as"${passthru[@]}""${passthru[@]+"${passthru[@]}"}"— the${var+alt}form that expands to nothing when the array is emptyThe Problem
cmd_uninstallinitialiseslocal passthru=()and then calls:With
set -euo pipefailat the top of the script, the-uflag causes bash 3.2 (the version shipped with macOS) to treat an empty-array expansion as an unbound variable and abort.What's Changed
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 underset -u.Test Plan
aiwf uninstallruns without error when no extra flags are passedaiwf uninstall --purgestill forwards--purgecorrectly touninstall.shaiwf uninstall-allcompletes successfully🤖 Generated with Claude Code