Skip to content

Commit 787083b

Browse files
yasinBursaliclaude
andcommitted
chore(bash32): guard declare -A callers + route dream-cli validate through $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>
1 parent d5154c3 commit 787083b

6 files changed

Lines changed: 43 additions & 3 deletions

File tree

dream-server/dream-cli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,15 +1114,15 @@ cmd_config() {
11141114
validate)
11151115
cd "$INSTALL_DIR"
11161116
if [[ -x "$INSTALL_DIR/scripts/validate-env.sh" ]]; then
1117-
"$INSTALL_DIR/scripts/validate-env.sh" "$INSTALL_DIR/.env" "$INSTALL_DIR/.env.schema.json"
1117+
"$BASH" "$INSTALL_DIR/scripts/validate-env.sh" "$INSTALL_DIR/.env" "$INSTALL_DIR/.env.schema.json"
11181118
else
11191119
warn "validate-env.sh not found at $INSTALL_DIR/scripts/validate-env.sh"
11201120
warn "Make sure you're on a recent Dream Server release."
11211121
fi
11221122
echo ""
11231123
if [[ -x "$INSTALL_DIR/scripts/validate-manifests.sh" ]]; then
11241124
log "Validating extension manifests and compatibility..."
1125-
if "$INSTALL_DIR/scripts/validate-manifests.sh"; then
1125+
if "$BASH" "$INSTALL_DIR/scripts/validate-manifests.sh"; then
11261126
success "Extension manifests validated"
11271127
else
11281128
warn "Extension manifest validation reported issues. See output above."

dream-server/installers/phases/03-features.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
# Add new optional features to the Custom menu here.
2121
# ============================================================================
2222

23+
# Require Bash 4+ (associative arrays used for GPU topology/link maps)
24+
if (( BASH_VERSINFO[0] < 4 )); then
25+
echo "ERROR: $(basename "${BASH_SOURCE[0]}") requires Bash 4.0+ (current: $BASH_VERSION)" >&2
26+
echo " macOS ships Bash 3.2 due to licensing. Install a modern version:" >&2
27+
echo " brew install bash" >&2
28+
return 1 2>/dev/null || exit 1
29+
fi
30+
2331
dream_progress 18 "features" "Selecting features"
2432
if $INTERACTIVE && ! $DRY_RUN; then
2533
show_phase 2 6 "Feature Selection" "~1 minute"

dream-server/lib/progress.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
# Dream Server — Progress Bar Utilities
33
# Sourced by install-core.sh for download/install progress display
44

5+
# Require Bash 4+ (associative array PHASE_ESTIMATES used for phase timing)
6+
if (( BASH_VERSINFO[0] < 4 )); then
7+
echo "ERROR: $(basename "${BASH_SOURCE[0]}") requires Bash 4.0+ (current: $BASH_VERSION)" >&2
8+
echo " macOS ships Bash 3.2 due to licensing. Install a modern version:" >&2
9+
echo " brew install bash" >&2
10+
return 1 2>/dev/null || exit 1
11+
fi
12+
513
# ═══════════════════════════════════════════════════════════════
614
# PROGRESS BAR
715
# ═══════════════════════════════════════════════════════════════

dream-server/scripts/dream-test-functional.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
# This complements dream-test.sh which checks service health.
1212
#=============================================================================
1313

14+
# Require Bash 4+ (associative arrays used for service-port lookup)
15+
if (( BASH_VERSINFO[0] < 4 )); then
16+
echo "ERROR: $(basename "$0") requires Bash 4.0+ (you have $BASH_VERSION)" >&2
17+
echo " macOS ships Bash 3.2 due to licensing. Install a modern version:" >&2
18+
echo " brew install bash" >&2
19+
exit 1
20+
fi
21+
1422
set -euo pipefail
1523

1624
# Colors
@@ -31,7 +39,7 @@ if [[ -f "$_FT_DIR/lib/service-registry.sh" ]]; then
3139
fi
3240

3341
# Ensure SERVICE_PORTS is declared even if service-registry.sh was not sourced
34-
declare -A SERVICE_PORTS 2>/dev/null || true
42+
declare -A SERVICE_PORTS
3543

3644
# Service endpoints — resolved from registry
3745
LLM_URL="${LLM_URL:-http://localhost:${SERVICE_PORTS[llama-server]:-11434}}"

dream-server/scripts/pre-download.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
# Cache location: ~/.cache/huggingface/hub/
1818
#=============================================================================
1919

20+
# Require Bash 4+ (associative arrays used for tier → model mapping)
21+
if (( BASH_VERSINFO[0] < 4 )); then
22+
echo "ERROR: $(basename "$0") requires Bash 4.0+ (you have $BASH_VERSION)" >&2
23+
echo " macOS ships Bash 3.2 due to licensing. Install a modern version:" >&2
24+
echo " brew install bash" >&2
25+
exit 1
26+
fi
27+
2028
set -euo pipefail
2129

2230
# Colors

dream-server/scripts/validate-env.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
# - Validate required keys, unknown keys, types, enums, and numeric ranges
88
# - Fail deterministically with a single exit code for CI
99

10+
# Require Bash 4+ (associative arrays used for env key/value/line tracking)
11+
if (( BASH_VERSINFO[0] < 4 )); then
12+
echo "ERROR: $(basename "$0") requires Bash 4.0+ (you have $BASH_VERSION)" >&2
13+
echo " macOS ships Bash 3.2 due to licensing. Install a modern version:" >&2
14+
echo " brew install bash" >&2
15+
exit 1
16+
fi
17+
1018
set -euo pipefail
1119

1220
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

0 commit comments

Comments
 (0)