$ BASH_VERSION报告了macOS上bash的旧版本,这是应该解决的问题吗? [英] $BASH_VERSION reports old version of bash on macOS, is this a problem that should be fixed?

查看:245
本文介绍了$ BASH_VERSION报告了macOS上bash的旧版本,这是应该解决的问题吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了自制软件的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆