How to update bash on Mac OS X Yosemite
Solution 1:
Your problem is in your first line. You have this:
#!/bin/bash
which explicitly states that the shell script should be ran with the old /bin/bash
.
What you really want, is this:
#!/usr/local/bin/bash
to use the new bash
from /usr/local/bin
.
Solution 2:
Install new bash:
brew install bash
Make this the default shell:
chsh -s /usr/local/bin/bash
Set the environment in a script:
#!/usr/bin/env bash
Using env
will look for Bash in your $PATH
and use the first one it encounters. You can see which bash
it will use by typing which bash
. If it's seeing /bin/bash
first, you will need to set your $PATH
in ~/.bashrc
and /.bash_profile
.