Skip to main content

Upgrade bash on macOS

·151 words·1 min
Kostiantyn Lysenko
Author
Kostiantyn Lysenko

macOS ships an old 3.x bash. Most Linux hosts have bash 4.x or 5.x. That mismatch makes scripts you wrote on Linux misbehave on your Mac (and vice versa) for no good reason.

Note (2026): macOS Catalina (2019) and later default to zsh, not bash. This post still applies if you’re explicitly using bash — but most users have moved on. Apple kept bash 3.2 in /bin/bash for license reasons (GPLv3 avoidance). Homebrew installs a newer bash to /opt/homebrew/bin/bash (Apple Silicon) or /usr/local/bin/bash (Intel).

Install via Homebrew
#

brew install bash

That installs current bash (5.x as of 2019, 5.2+ in 2026) alongside Apple’s /bin/bash. To make it your default:

# Add the new shell to /etc/shells
sudo bash -c "echo $(brew --prefix)/bin/bash >> /etc/shells"

# Change your login shell
chsh -s $(brew --prefix)/bin/bash

Verify:

$ bash --version
GNU bash, version 5.0.2(1)-release (x86_64-apple-darwin18.2.0)

Much better.

References
#


comments powered by Disqus