Wednesday, March 19, 2014

Install bash 4.2.45 in 3 minutes or less

So here we go.

I set PS1 to '\t \$ ' in order to document the time required to do this. Everything was typed by hand and done from memory except a short alt-tab to nvALT to ensure proper numbering for curl'ing the patches.

  • md src
  • curl -OL http://ftpmirror.gnu.org/bash/bash-4.2.tar.gz
  • tar xzf bash-4.2.tar.gz
  • cd bash-4.2
  • md patches
  • curl -L "http://mirror.anl.gov/pub/gnu/bash/bash-4.2-patches/bash42-0[01-45]" -o "bash42-0#1"

step 1 - 6
  • cd ..
  • for patchfile in ./patches/*; do patch -p0 <"$patchfile"; done

step 7-8
  • ./configure
  • make -j4
  • sudo make install

Done!
To wrap up simply edit /etc/shells like in my previous post and chsh -s on your user.




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 http://ftpmirror.gnu.org/bash/bash-4.3.tar.gz
tar xzf bash-4.3.tar.gz
cd bash-4.3
./configure
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.
/etc/shells
Sweet sweet victory!
$BASH_VERSION

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