我尝试从/usr/local/Cellar/bash/4.4.19/bin/bash
复制到/usr/local/bin/bash
,因为which bash
显示/usr/local/bin/bash
。
~/cat /etc/shells
/usr/local/Cellar/bash/4.4.19/bin/bash
~/bash --version
GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin17.3.0)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
echo $BASH_VERSINFO
3
我该如何解决这个问题?
答案 0 :(得分:5)
bash --version
显示如果从PATH启动新shell,将运行的版本。因此,此版本与来自which bash
的安装位置(如果未被别名/函数/等修改)或type bash
(更准确地说)或与用于运行脚本的shell相关联与#!/usr/bin/env bash
shebang。
$BASH_VERSINFO
和$BASH_VERSION
显示正在运行的版本。因此,如果您的脚本中包含#!/bin/bash
shebang,或者密码数据库指定/bin/bash
作为其shell的用户的交互式shell脚本,/usr/local/bin/bash
(或任何在PATH中较早的其他位置与当前的,未从PATH shell实例开始的目的无关。
#!/usr/bin/env bash
。要从交互式会话中启动指定的shell,请使用chsh
更新帐户的设置。