Why MacOS Changed the Default Shell From bash to zsh
If you are familiar with older versions of MacOS, when MacBooks still had Intel CPUs, touchbars, and thick bezels, the default shell providing a command line interface was bash. The version of the bash shell that MacOS provides is version 3.2, which is from the year 2006.
The older versions of the bash shell was distributed under the GNU GPL v2 license, and Apple was perfectly happy to comply with the terms of the license when bundling it with MacOS. However, after bash 3.2, newer versions from bash 4.0 right up to the latest version 5.2 are distributed under the GNU GPL v3 license. The GPL3 license includes additions to prevent Tivo-ization (blocking the installation or use of software other than that of the manufacturer or vendor) and granting a license to patents required for the use of the software. Because of the change in licensing terms, Apple adopted zsh, a shell distributed under the MIT license.
It is still possible to install newer versions of bash - this is often done easily with HomeBrew using the command brew install bash
. To make the newer version of bash the default for the user, first locate the bash executable with the command which -a bash
, then enter the path into the /etc/shells text file, and run the command chsh -s <path-to-new-bash>
.
It is possible to replace the existing system bash binary by disabling System Integrity Protection - this is done by restarting in recovery mode and running csrutil disable
. However, the newer bash binaries can be used by ensuring that the she-bang within shell scripts uses /usr/bin/env bash
instead of /bin/bash
.