Are there any disadvantages to using the brew version of bash for /bin/sh?

Solution 1:

I would advise against making the Homebrew installation of bash your system-wide bash or sh command. However it should be fine to use as your personal shell.

Homebrew provides a vanilla installation of Gnu Bash. You will be missing any Apple additions to the shell that are provided if you use the Apple-supplied bash or sh binaries or source code from Apple's opensource.apple.com site. Any OS-level shell script provided by Apple may be relying on those Apple extension and changes to function.

Homebrew also installs, by default, a 4.3.x version of bash:

> brew info bash
bash: stable 4.3.24 (bottled), HEAD
http://www.gnu.org/software/bash/
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/bash.rb
==> Dependencies
Required: readline ✘
==> Caveats
In order to use this build of bash as your login shell,
it must be added to /etc/shells.

This is a significantly different version than the 3.2.x version that ships with OS X 10.9.x. It is not 100% backwards compatible with pre 4 versions. For example substring extraction on positional parameters indexing changed from 3 to 4. It could break system-level scripts.

Both of those reasons can lead to inoperable system scripts on your Mac if you switch to Homebrew's versions of bash and sh for anything other than your personal shell. You can make your personal shell the Homebrew bash shell by running:

chsh -s /usr/local/bin/bash

and then logging out and logging back in. This should be relatively safe for the stable operation of your machine.

If the above chsh command fails saying /usr/local/bin/bash is not an acceptable shell you'll need to add it to the list in /etc/shells by running:

sudo vim /etc/shells

It should be added on a new line in the file like so:

> cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/zsh
/usr/local/bin/bash