I am running El Capitan 10.11.3 with bash version 3.x so I decided to update bash via:
brew install bash
Brew places the new bash under /usr/local/Cellar/bash:
brew info bash
bash: stable 4.3.42 (bottled), devel 4.4-beta, HEAD
Bourne-Again SHell, a UNIX command interpreter
https://www.gnu.org/software/bash/
/usr/local/Cellar/bash/4.3.42 (59 files, 7.3M) *
Poured from bottle
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.
As you can see brew mentions that I need to update /etc/shells
in order to use the new bash. But after closing/reopening the current shell bash --version
tells me that now I am already using 4.3.42 so I wonder what happened under the hood that the new version is automatically used?
Best Answer
You can use the chsh command to change your shell. In your case, with brew generated bash, you should set it to
/usr/local/bin/bash
. You should also put this in/etc/shells
.As to your question
echo $BASH_VERSION
will tell you the version of the current shell.bash --version
tells you the version of the first bash in your$PATH
. So the way you were looking at the version was not telling you the version that you were running.