I tried to change default bash on OS X Mavericks,

  • Installed new bash trough brew,
  • run chsh -s /usr/local/bin/bash,
  • went to "Users and group" made sure that Login shell for my login points to the same, added path to /etc/shells, rebooted machine.

now echo $BASH_VERSIONshows 4.2.45(2)-release

but sh --version still says GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)

Which one is true?

And if the second one, then what am I doing wrong, why it wouldn't switch to bash I installed?


Version Info

Like this:

$ bash --version
GNU bash, version 4.2.45(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

NOTE: Use caution since sh and bash aren't the same thing. sh is Bourne Shell while Bash is Bourne Again Shell.

Where is it?

Also in your case when you run sh you're picking up sh from /bin or /usr/bin. The Bash you installed via brew isn't likely on the $PATH, it's in /usr/local/bin.

Always try to get in the habit of querying the system as to "where" on the disk a given executable is coming from.

$ type bash
bash is hashed (/usr/bin/bash)

$ type sh
sh is /usr/bin/sh

Expunging from hash

To get Bash to unhash the location of bash you can use the hash command:

$ hash -d bash
$ type bash
bash is /usr/bin/bash


You can make the newly installed Bash the preferred one by ordering your $PATH slightly different.

$ export PATH=/usr/local/bin:$PATH
  • yes... it's still not showing the new version. It points to the old (hashed) one... How do I force it to use the new one? – iLemming Feb 23 '14 at 8:33
  • @Agzam - see updates. – slm Feb 23 '14 at 8:35
  • now it doesn't say hashed, but still points to /bin/bash – iLemming Feb 23 '14 at 8:37
  • Oh... it worked when I deleted /bin/bash :) – iLemming Feb 23 '14 at 8:39
  • @Agzam - That's the PATH. I probably wouldn't delete it. Just put your /usr/local/bin in the front part of the PATH. export PATH=/usr/local/bin:$PATH. The hash is just a look up that Bash maintains so it doesn't have to crawl the disk everytime. – slm Feb 23 '14 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.