Skip to content

Conversation

@ai-tesi
Copy link
Contributor

@ai-tesi ai-tesi commented Jan 27, 2026

Summary

  • Skip loading doctor.sh on bash < 4 to fix curl | bash install on macOS

Problem

macOS ships with bash 3.2 (from 2007). When running:

curl -sSL https://raw.githubusercontent.com/mbailey/metool/master/install.sh | bash

The installer fails with:

declare: -g: invalid option

This is because lib/doctor.sh uses declare -g which requires bash 4+.

Solution

Conditionally load doctor.sh only when bash 4+ is available:

if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
  source "${MT_ROOT}/lib/doctor.sh"
fi

Trade-offs

  • mt doctor command won't be available on bash 3.2
  • All other functionality works normally
  • Once Homebrew bash is installed, mt doctor becomes available

Testing

Tested on fresh macOS Tahoe VM (arm64) with bash 3.2.57:

  • Before: install.sh fails immediately with declare error
  • After: install.sh completes successfully

Alternative Considered

Full bash 3.2 compatibility would require rewriting:

  • declare -g → plain assignments (easy)
  • declare -A → parallel arrays (hard)
  • mapfile → while-read loops (medium)
  • ${var^^}tr calls (medium)

This minimal fix unblocks installs without major refactoring.


🤖 Generated with Claude Code

doctor.sh uses `declare -g` which requires bash 4+. macOS ships with
bash 3.2, causing install.sh to fail when run via curl | bash.

This change conditionally loads doctor.sh only when bash 4+ is available.
The `mt doctor` command won't be available on bash 3.2, but core install
functionality works.

Tested on macOS Tahoe (arm64) fresh VM with bash 3.2.57.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mbailey mbailey merged commit ef3188a into mbailey:master Jan 27, 2026
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.

2 participants