前置き
Mac OS10.15 Catalina の 標準 shell は Bash ではなく、zsh になりました。
アップデートしたら zsh に強制的に変更されるということはないですが、以下のような文がターミナルを起動するたびに表示されます。
私の環境では、 .bashrc や .bash_profile を作り込んでいるので、 zsh に移行すると色々と不具合が出ました。
今回は、zsh への移行は延期することにしました。どうやら、警告文を消す方法が、Bash のインストールでできるようですのでそちらを試してみたいと思います。
※ 今回実行した方法では、Bash3系からBash5系にバージョンが上がるので、互換性がないかもしれないです。
Bash 最新版をインストール
Mac OS10.14 Mojave のデフォルトは、以下の通り。
最新バージョンが5系なので、古いです。
$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.
今回は、brew を使用して最新版をインストールします。
$ brew install bash
$ /usr/local/bin/bash --version
GNU bash, バージョン 5.0.11(1)-release (x86_64-apple-darwin19.0.0)
Copyright (C) 2019 Free Software Foundation, Inc.
ライセンス GPLv3+: GNU GPL バージョン 3 またはそれ以降 <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.
インストールが完了したら、/etc/shells
に/usr/local/bin/bash
を追加します。
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/bash ← これを追加
使用する shell を指定
shell の変更は、chsh -s <使用するshellのパス>
で指定できます。
$ chsh -s /usr/local/bin/bash
確認
インストール完了後、ターミナルを閉じます。
再度開くと zsh への変更を促す文も表示されることなく、Bash のバージョンも最新の5系に切り替わります。