$BASH_VERSION reports old version of bash on macOS, is this a problem that should be fixed?

后端 未结 3 635
闹比i
闹比i 2020-12-03 23:04

I have homebrew\'s bash package installed. When I open a new shell:

bash --version gives GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin18

3条回答
  •  庸人自扰
    2020-12-03 23:58

    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
    

    After logging out and in again, $BASH_VERSION should be updated.

    As for shebang lines, I recommend

    #!/usr/bin/env bash
    

    as it's portable and will use the first Bash in your $PATH.

提交回复
热议问题