There are always more man pages to discover.

Upgrade to Bash 4 on Mac OSX

I came across some article regarding dictionary array for bash 4. I wanted to try it out but I am currently running bash 3.2 in Mac OSX Maverick. I came across this article on how to use homebrew to upgrade to bash 4 and ran into a few problems.

First, after I run

brew install bash

I got an error saying there is a permission error for /usr/local/share/info. I changed the owner of the folder to me and rerun the linking process.

sudo chown $(whoami) /usr/local/share/info
brew link bash

Everything seems to be working. Now I following the article and add /usr/local/bin/bash to /etc/shells and run chsh -s /usr/local/bin/bash (see link below). So I check my bash version to see what happen.

bash --version
GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin13)
Copyright (C) 2007 Free Software Foundation, Inc.

Ok. What is going on? I went and changed the Terminal Preference in Shells open with: Command (complete path) to /usr/local/bin/bash under Startup and still have the old version. Here I suspect that when I run the version check, I am not checking what the version open by the terminal but the /bin/bash version. Finally, I found out that there is an environment variable BASH_VERSION that I can check for the current bash environment that I am running.


Bingo. It works. I changed my preference back to Default login shell and still give me the update version.

Additional References:

Adding PATH

TO add a PATH to the existing one.

For Mac:

$ open -a TextEdit ~/.bash_profile
export PATH=/path/to/the/folder:$PATH

$ source ~/.bash_profile
$ echo $PATH

Add the export line into the .bash_profile. Use the source command to update the path and use echo command to verify the path has been added.

Similarly, using vi/m, gedit or other text editor, add the export line into ~/.bash_profile the same way in Linux.

HINT: use \ in front of space to include them if they are part of the folder name.