chore(bash32): guard declare -A callers + route dream-cli validate through $BASH#1011
Draft
yasinBursali wants to merge 1 commit intoLight-Heart-Labs:mainfrom
Draft
chore(bash32): guard declare -A callers + route dream-cli validate through $BASH#1011yasinBursali wants to merge 1 commit intoLight-Heart-Labs:mainfrom
yasinBursali wants to merge 1 commit intoLight-Heart-Labs:mainfrom
Conversation
…rough $BASH Five scripts used declare -A (bash 4+ associative arrays) without the safety net already present in dream-cli and lib/service-registry.sh: - scripts/pre-download.sh (user-invoked per FAQ.md) - scripts/dream-test-functional.sh (dev/test tool) - scripts/validate-env.sh (invoked by dream config validate) - lib/progress.sh (sourced by install-core.sh) - installers/phases/03-features.sh (sourced by install-core.sh) On macOS the system /bin/bash is 3.2.57 and declare -A fails with a cryptic "invalid option" error. Pattern A guards (standalone scripts) use bare exit 1; Pattern B guards (sourced libs) use "return 1 2>/dev/null || exit 1", matching the accepted patterns in dream-cli:8-14 and lib/service-registry.sh:18-24. Also makes dream config validate functional on macOS by invoking the sibling subprocesses through "$BASH", so the modern bash that dream-cli is running under is inherited by validate-env.sh and validate-manifests.sh rather than being re-resolved through their #!/bin/bash shebang. Removes a dead "2>/dev/null || true" fallback on declare -A SERVICE_PORTS in dream-test-functional.sh; surrounding set -e + the service-registry guard already abort the script before that line under bash 3.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Marked as draft pending merge of #994. This PR overlaps with open PR #994 (
Once #994 lands, I'll rebase this branch; the duplicate changes will drop automatically and the remaining scope is:
Will un-draft and request review after the post-#994 rebase is clean. |
Collaborator
|
Audit follow-up: keep draft and rebase after the strict-mode foundations. The Bash 4 compatibility guard direction is reasonable, but this branch overlaps with the strict-mode/pipefail stack that has now partially landed. Please rebase on current |
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.
What
Adds Bash 4+ guards to five scripts that use
declare -Awithout one, and routes twodream config validatesubprocesses through"$BASH"so they inherit dream-cli's modern bash interpreter.Files touched (6):
dream-server/scripts/pre-download.sh— Pattern A guard (bareexit 1)dream-server/scripts/dream-test-functional.sh— Pattern A guard + drop dead2>/dev/null || truefallback ondeclare -A SERVICE_PORTSdream-server/scripts/validate-env.sh— Pattern A guarddream-server/lib/progress.sh— Pattern B guard (return 1 2>/dev/null || exit 1)dream-server/installers/phases/03-features.sh— Pattern B guarddream-server/dream-cli— prefix validate-env.sh and validate-manifests.sh subprocess execs with"$BASH"Guard style mirrors
dream-cli:8-14(Pattern A, standalone scripts) andlib/service-registry.sh:18-24(Pattern B, sourced libraries).Why
On macOS, system
/bin/bashis 3.2.57, which does not support associative arrays. Two user-facing problems:./scripts/pre-download.sh --tier 3from FAQ.md) produced a crypticdeclare -A: invalid optioncrash with no actionable hint.scripts/validate-env.shvia shebang — which re-resolves to/bin/bash3.2 regardless of the parent interpreter.dream config validatewas silently non-functional on macOS for users without bash in PATH.Guards turn (1) into a friendly error with a
brew install bashhint. The"$BASH"prefix makes (2) work by inheriting the parent interpreter.How
set -euo pipefailand before the firstdeclare -A. Pattern B usesreturn 1 2>/dev/null || exit 1so sourced-vs-exec'd-direct both behave correctly.dream-cli:1117and:1125:"$INSTALL_DIR/scripts/<script>.sh" ...→"$BASH" "$INSTALL_DIR/scripts/<script>.sh" ....$BASHis bash's own path to its interpreter; since dream-cli guards at line 9 require Bash 4+,$BASHis guaranteed to point at a modern bash when this code runs.Testing
bash -nsyntax check — all 6 files passshellcheck— per-file warning counts identical between upstream/main and PR (no new diagnostics). SC2317 on Pattern Bexit 1is accepted baseline, identical toservice-registry.sh:23.make lint— clean/bin/bash. Pattern B sourced-path correctly propagates non-zero$?to the caller without aborting the parent shell.lib/service-registry.sh:20("Install a modern version") for consistency.Platform Impact
dream config validatenow works without requiring the user to manually invoke via/opt/homebrew/bin/bash. Direct invocations of the 5 scripts under system bash produce a clean error message instead of a cryptic crash.