Old bash version on MacOS ?

What? An older bash version?

Are you seeing and still not believing on something like below,

MacBook-Pro:~$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
Copyright (C) 2007 Free Software Foundation, Inc.

Well that is my MBP as of Mar 29, 2017 running MacOS Sierra Version 10.12.4 Beta (16E192b).

 

So here is what I did,

MacBook-Pro:~$ brew install bash

 

And later bash --version reported 4.4.12(1) 😉

MacBook-Pro:~$ bash --version
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

 

Well one more thing, if you haven’t figured that things aren’t working as expected!

Either,

  1. Add/ Change the shebang on the scripts to #!/usr/local/bin/bash, OR
  2. Modify line /bin/bash in file /etc/shells to /usr/local/bin/bash

 

Configure terminal to use it

# Add the new shell to the list of allowed shells
sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells'
# Change to the new shell
chsh -s /usr/local/bin/bash

 

References

  1. http://stackoverflow.com/questions/6047648/bash-4-associative-arrays-error-declare-a-invalid-option
  2. http://clubmate.fi/upgrade-to-bash-4-in-mac-os-x/

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *