$ BASH_VERSION报告了macOS上bash的旧版本,这是应该解决的问题吗? [英] $BASH_VERSION reports old version of bash on macOS, is this a problem that should be fixed?
问题描述
我安装了自制软件的bash软件包.当我打开一个新的外壳程序时:
I have homebrew's bash package installed. When I open a new shell:
bash --version
给出GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin18.5.0)
which bash
给出了预期的/usr/local/bin/bash
.
但是:
echo $BASH_VERSION
产生3.2.57(1)-release
我想知道是否应该针对可能使用此环境变量的脚本解决这个问题.
I'm wondering if this is something I should address for scripts that might use this environment variable.
推荐答案
这意味着您所在的外壳是Bash 3.2,但bash
指向Bash 5.0.尝试使用bash
,然后在新的shell中使用echo $BASH_VERSION
–我想它将是5.0.要更改您的登录外壳,请在/etc/shells
中添加/usr/local/bin/bash
并使用
It means that the shell you're in is Bash 3.2, but bash
points to Bash 5.0. Try bash
and then, in the new shell, echo $BASH_VERSION
– I guess it'll be 5.0. To change your login shell, add /usr/local/bin/bash
to /etc/shells
and change the default shell with
chsh -s /usr/local/bin/bash
sudo chsh -s /usr/local/bin/bash
注销并再次登录后,应更新$BASH_VERSION
.
After logging out and in again, $BASH_VERSION
should be updated.
关于shebang行,我建议
As for shebang lines, I recommend
#!/usr/bin/env bash
它是便携式的,将使用您的$PATH
中的第一个Bash.
as it's portable and will use the first Bash in your $PATH
.
这篇关于$ BASH_VERSION报告了macOS上bash的旧版本,这是应该解决的问题吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!