无法在 Mac OS X 中更改 bash shell

che*_*kha 9 osx shell bash homebrew

我正在尝试更新bashMac OS Mavericks 上的 shell。

$ brew install bash
$ which -a bash
/bin/bash
/usr/local/bin/bash

$ which bash
/bin/bash

$ chsh -s /usr/local/bin/bash
$ which bash
/bin/bash
Run Code Online (Sandbox Code Playgroud)

在终端的首选项中:Shells open with -> Command (complete path) : /usr/local/bin/bash

但是,我仍然无法切换到 brew 安装的 bash shell。我能做什么?

Ant*_*Ant 21

chsh手册:

当更改登录 shell 而不是超级用户时,用户不能从非标准 shell 更改为非标准 shell。非标准被定义为在/etc/shells.

所以你可以chsh以root身份运行

sudo chsh -s /usr/local/bin/bash "$USER"
Run Code Online (Sandbox Code Playgroud)

或添加/usr/local/bin/bash/etc/shells使其成为“标准外壳”

echo /usr/local/bin/bash | sudo tee -a /etc/shells
chsh -s /usr/local/bin/bash
Run Code Online (Sandbox Code Playgroud)

需要注意的是,事实which bash仍然指向/bin/bash并不意味着你的shell还没有改变,它只是意味着/bin是之前/usr/local/bin在你的$PATH