Installing GNU Bash 5.2 on MacOS (tested on Monterey 12.3)

If you like /bin/bash on a Mac, but are tired of this message.

$ /bin/bash
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

Then you need to upgrade bash on your Mac. To be honest, the version that ships is quite old (3.2) and really should not be used.

The correct thing to do is to install a new version of bash on your system.... which you can do by downloading the Bash source, then compiling.

Steps to do this are as follows:

  • Install GCC. If you don't have it go here and download precompiled gcc binaries OR follow the steps to compile.
  • Download Bash-5.2 source from https://ftp.gnu.org/gnu/bash/bash-5.2.tar.gz and extract into a working directory
  • cd bash-5.2
  • ./configure --prefix=/usr/local/bash
  • make
  • make install (as root)
  • the bash module will now be installed under /usr/local/bash
  • create sym links for all files under /usr/local/bash/bin to /usr/local/bin
  • ln -s /usr/local/bash/bin/bash /usr/local/bin/bash
  • ln -s /usr/local/bash/bin/bashbug /usr/local/bin/bashbug
  • add the following line /etc/shells
    • /usr/local/bin/bash
  • chsh your user and change the shell from /bin/bash to /usr/local/bin/bash then restart terminal.