fix(mac-launcher): bash 3.2-safe empty-array expansion (fixes "EXTRA[@]: unbound variable")#154
Merged
Conversation
…ound variable)
scripts/run_kakeya_mac.sh used 'set -u' + a bare "${EXTRA[@]}". macOS's default
/bin/bash is 3.2, where expanding an EMPTY array under nounset errors with
'EXTRA[@]: unbound variable' — hit when the launcher is run with no pass-through
args (the common interactive case). Use the canonical ${EXTRA[@]+"${EXTRA[@]}"}
form (elements if set, nothing if empty, no nounset error). Add
mlx-kakeya-launcher-dryrun-bash32 preset to guard it on the real /bin/bash 3.2.
Co-authored-by: FluffyAIcode <FluffyAIcode@users.noreply.github.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
scripts/run_kakeya_mac.shdied withline 83: EXTRA[@]: unbound variablewhen run with no pass-through args (the common interactive case).Root cause
The script uses
set -euo pipefail(nounset) and expanded a possibly-empty array with a bare"${EXTRA[@]}". macOS's default/bin/bashis 3.2 (Apple froze it at GPLv2), where expanding an empty array undernounsetis treated as an unbound-variable error. (bash ≥4.4 — e.g. my Linux dev shell — does not error, which is why it slipped through.) With pass-through argsEXTRAis non-empty so it worked; with none it crashed.Fix
Use the canonical bash-3.2-safe form
${EXTRA[@]+"${EXTRA[@]}"}— expands to the quoted elements when set, to nothing when empty, and never tripsnounset.Validation (Mac M4, on the actual /bin/bash 3.2)
New
mlx-kakeya-launcher-dryrun-bash32preset runs/bin/bash scripts/run_kakeya_mac.sh --dry-run(emptyEXTRA, the exact failing condition). Result: exit 0, prints the resolved command — noEXTRA[@]: unbound variable. Pre-fix it died at line 83 on the same bash.Also verified locally: dry-run with empty
EXTRA(works), with pass-through args (included), and the idiom underset -u(empty → nothing,populated → elements).Testing
mlx-kakeya-launcher-dryrun-bash32on macOS/bin/bash3.2 (exit 0, command printed)pytest tests/inference_engine/bridge/test_manifest.py(31 passed)bash -n scripts/run_kakeya_mac.shIndependent fix off
main. Note: pending launcher PRs #148/#150 also touch this file; whichever merges after should keep the${EXTRA[@]+…}form.