简体   繁体   English

无法通过MacPorts更新Mac中的Bash

[英]Unable to update my Bash in Mac by MacPorts

I updated unsuccessfully my Bash to 3.2.48 by MacPorts. 我通过MacPorts将我的Bash更新为3.2.48失败了。

It seems that I do not have it active, since I get 因为我得到了,似乎我没有活跃

echo $BASH_VERSION
3.2.17(1)-release

How can you make the newest Bash active such that I get it for my login shell? 你怎么能让最新的Bash活跃起来 ,以便我为我的登录shell获取它?

Run the following code, for instance to change your shell to the newest Bash installed by MacPorts 运行以下代码,例如将shell更改为MacPorts安装的最新Bash

chsh -s /opt/local/bin/bash

If that gives you the message, 如果这给你的信息,

" non-standard shell " non-standard shell

you will need to add 你需要添加

/opt/local/bin/bash

to

/etc/shells

Note that /etc/shells is just a text file, so you can edit it directly if you authenticate as root. 请注意/etc/shells只是一个文本文件,因此如果您以root身份进行身份验证,则可以直接编辑它。 You can programmatically change it by the command 您可以通过命令以编程方式更改它

sudo -s
Password:
# echo /opt/local/bin/bash >> /etc/shells

If your first chsh command failed, run it now again if you managed to change the above file. 如果您的第一个chsh命令失败,如果您设法更改上述文件,请立即再次运行它。

You can switch your login shell, from your existing Mac OS X login shell (by default its /bin/bash shipped with Mac OS X), to MacPorts /opt/local/bin/bash just by using the following shell script: 您可以使用以下shell脚本将登录shell从现有的Mac OS X登录shell(默认情况下为Mac OS X附带的/bin/bash )切换到MacPorts /opt/local/bin/bash

#!/opt/local/bin/bash
if [ `grep /opt/local/bin/bash /etc/shells` ]; 
then 
    echo /opt/local/bin/bash | chsh -s /opt/local/bin/bash;     
else 
    echo /opt/local/bin/bash | sudo tee -a /etc/shells; 
    chsh -s /opt/local/bin/bash; 
fi

I'm guessing it's installed but not being used as your login shell. 我猜它已经安装但没有被用作你的登录shell。

You can change the shell using dscl on the command line. 您可以在命令行上使用dscl更改shell。

At the dscl prompt type the following: 在dscl提示符下键入以下内容:

list Local/Default/Users
read Local/Default/Users/<your username here>
change Local/Default/Users/<your username here> UserShell /bin/bash /opt/local/bin/bash

I have another example of dscl use on my blog if it helps. 如果有帮助,我在我的博客上有另一个dscl使用示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM