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