码迷,mamicode.com
首页 > 系统相关 > 详细

Mac升级bash到最新版本

时间:2018-02-14 11:44:10      阅读:1006      评论:0      收藏:0      [点我收藏+]

标签:最新版   sip   机制   body   pre   bin   command   local   bash   

mac自带的bash为3.2版本,而最新的bash是4.9,需要升级了,才能支持关联数组等新特性。

1、brew install bash

2、安装到/usr/local/bin/bash里面。可以通过修改/etc/shells文件,来完成开机使用新版本的bash

3、但是,无法改变/bin/bash的版本,这里仍旧为3.2版本,这给使用脚本带来不便,因为默认都是#!/bin/bash

4、细查后,发现原来mac系统禁止更改系统目录的权限,引入sip机制,需要先关闭,修改,再打开这一系列操作。

5、下面是打开和关闭sip的步骤。

(1)重启OSX系统,然后按住Command+R

(2)出现界面之后,选择Utilities menu中Terminal

(3)在Terminal中输入csrutil disable关闭SIP(csrutil enable打开SIP)

(4)重启reboot OSX

6、关闭sip后,加入软连接,在打开sip

sudo mv /bin/bash  /bin/bash.origin
sudo ln -s /usr/local/bin/bash /bin/bash

 

Mac升级bash到最新版本

标签:最新版   sip   机制   body   pre   bin   command   local   bash   

原文地址:https://www.cnblogs.com/litifeng/p/8448019.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!