Reputation: 9767
I tried copying from /usr/local/Cellar/bash/4.4.19/bin/bash
to /usr/local/bin/bash
because which bash
shows /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
How do I fix this?
Upvotes: 1
Views: 1425
Reputation: 295500
bash --version
shows the version that would be run if a new shell were started from the PATH.Thus, this version correlates with the install location from which bash
(if not modified by aliases/functions/etc), or type bash
(more accurately), or with the shell used to run a script with a #!/usr/bin/env bash
shebang.
$BASH_VERSINFO
and $BASH_VERSION
show the version that's running right now.Thus, if you're in a script with a #!/bin/bash
shebang, or an interactive shell script for a user whose password database specifies /bin/bash
as their shell, /usr/local/bin/bash
(or any other location) being earlier in the PATH is irrelevant for purposes of the current, not-started-from-the-PATH shell instance.
#!/usr/bin/env bash
. To start a specified shell from an interactive session, use chsh
to update your account's settings.Upvotes: 7