Latest bash on Catalina with MacPorts

Install XCode via the App Store.

Install XCode command-line tools:

xcode-select --install

Change your shell from zsh to the ancient version of bash that Apple supplies:

chsh -s /bin/bash

Install MacPorts.

Open a new terminal window, which will now have MacPorts paths in $PATH.

Install latest bash with MacPorts:

sudo port install bash

Add the new bash as a valid shell:

sudo vi /etc/shells

Add /opt/local/bin/bash to the list of valid shells.

Change your shell to the new bash:

chsh -s /opt/local/bin/bash

Open a new terminal window and verify that in fact, you are running the latest bash:

$ bash --version
GNU bash, version 5.0.16(1)-release (x86_64-apple-darwin19.3.0)

Bash scripts with #!/bin/bash at the top will still run bash 3.2.57. Using env is one way to get around this; read Daniel's article below.

Note that nobody is saying zsh is not cool.

Reference: Upgrading Bash on macOS by Daniel Weibel.

Topic: