The Mac comes with Bash 3.2, and the latest bash is 4.9 and needs to be upgraded to support new features like associative arrays.
1. Brew Install Bash
2, install into the/usr/local/bin/bash inside. You can complete the boot using the new version of Bash by modifying the/etc/shells file.
3, however, can not change the version of/bin/bash, here is still the 3.2 version, which is inconvenient to use the script, because the default is #!/bin/bash
4, after detailed investigation, found that the original Mac system is forbidden to change the permissions of the system directory, the introduction of SIP mechanism, need to close, modify, and then open this series of operations.
5. Here are the steps to open and close the SIP.
(1) Restart the OSX system, then press command+R (2) to display the interface, select Utilities Menu terminal (3) Enter csrutil disable in terminal to close SIP (csrutil enable SIP) (4) restart reboot OSX
6. After the SIP is closed, add a soft connection to open the SIP
sudo mv/bin/bash /bin/-s/usr/local/bin/bash/bin/bash
Mac upgrade Bash to the latest version