Updating Your Bash
My machine was using bash 3.2.48 and the most recent version of bash is 4.2. In this post I’ll walk you through the steps needed to update your bash.
But first, an unexpected and exciting (and brief) look into tar files! TAR stands for Tape Archive. Why? Well, originally it was designed for tape backups. What the heck is a tape? There’s a device called a tape drive that reads and writes data on a magnetic tape. Check it out!
Wow! That thing looks like it’s a hundred years old! In contrast to a disk drive, which can move to any position on the disk in milliseconds to retrieve data, a tape drive must physically wind tape between reels to read data. But what you lose in speed you make up in cost. Tape drives are much less expensive.
So we go grab this tar file of the newest version of bash. (Note: a tar does not compress the files).
First, click here to grab the tar of bash 4.2.
Enter the Downloads folder.
Let’s learn about some tar commands now that we have a tar file to deal with.
zuncompress before extracting
xis to extract files ending in .tar.gz or .tgz
vis to be verbose as it’s extracting
fis filename to follow
tar zxvf bash-4.2.tar.gz
Wait! What is this .tar.gz extension? Remember when I told you tar files aren’t compressed? .tar.gz files are compressed tar files, which is why we had to supply the
z flag to uncompress before extracting it.
Look at Wikipedia’s pretty picture of it all!
Alright, now hop into your brand new, freshly created bash-4.2 folder.
Now we’ll just run three commands in a row all on one line. These three steps are very standard for obtaining software directly from the source code.
make install performs the install, also specified in the makefile (which is essentially a file of instructions). It’s common for this command to install executables after the compilation process is complete.
The binary is installed at /usr/local/bin/bash.
./configure && make && sudo make install
Change your login shell to the bash shell you just downloaded.
chsh -s /usr/local/bin/bash your_user_name
chsh only allows you to switch to the shells listed in /etc/shells, so we need to register the new binary as a valid shell. The bash manual tells us that if the -c option is present commands are read from string.
sudo bash -c "echo /usr/local/bin/bash >> /private/etc/shells"
Enter the bin folder.
Re-name bash folder to bash-old, thereby creating a “backup” copy.
sudo mv bash bash-old
Create a symlink to point /bin/bash to /usr/local/bin/bash.
sudo ln -s /usr/local/bin/bash bash
Now if you run this command you can check the version of bash you’re using.
And finally, read about the new stuff in bash 4.X.
Some Helpful Stuff