Friday, March 7, 2014

bash 4.3 install

I had intended this to be a post about how to quickly & easily install bash 4.2.45 but then I saw that 4.3 came out about two weeks ago.

Why would you want bash 4.x?

Welp. Bash 3.2.51 came out in March of 2010 and yet that is still the included version in Mavericks. Why else might you want bash 4? Here are a few of my favorites:
  1. globstar
  2. Zero padded brace expansion
  3. case changes via Parameter expansion
  4. Associative Arrays
Want to install bash 4.3? Here is a super fast way to do it:

md ~/src
curl -OL
tar xzf bash-4.3.tar.gz
cd bash-4.3
make -j4
sudo make install

Now the next thing we want to do is set it as our login shell so that we can use all these fun options by default. To do this we will use the chsh command but will probably run into an error.

$ chsh -s /usr/local/bin/bash
Changing shell for ryan.
Password for ryan:
chsh: /usr/local/bin/bash: non-standard shell

To see why this happens take a look at man shells. At this point I just want to fix it. Edit /etc/shells in your editor of choice and add /usr/local/bin/bash to the list of allowed shells, then run chsh again.
Sweet sweet victory!

EDIT: You might be leery of running two week old software as your login shell, next post I will show you how to install fully patched bash 4.2.45 from source in 3 minutes and 9 seconds! #whyyoudontneedbrew

No comments:

Post a Comment