# Shell と Bash のいろいろ
Bash とは Unix シェルの一種でコマンド言語である
Shell の英語翻訳は「殻」、システム上カーネル(kernel)とよく比較したり使う。Shell は複数の意味がある、1つは、OS のカーネルとコミュニティ行うインタフェースプログラムである。2つは、変数、判断、操作などのコマンド言語である。
Shell と Bash の違い
Bash は今一番使われている Shell であり、多くの場合 Bash イコール Shell
# Shell と Bash の歴史
1969 年、Ken Thompson と Dennis Ritchie は Unix 開発リリース
1971 年、Ken Thompson は初めての Shell、Thompson shell を開発、プログラム名 sh
1973 年から 1975 年の間、John R. Mashey は Thompson shell を拡張してプログラム機能入れ、Shell がプログラミング言語になった。このバージョンの Shell は Mashey shell という
1976 年、Stephen Bourne は Mashey shell を参考に Shell をリプレイスして Bourne shell バージョンをリリース
1978 年、カリフォルニア大学の Bill Joy は C 言語で C shell(csh) を開発
1979 年、Unix V7 リリース。Bourne Shell は Unix のデフォルト Shell としてインストール
1983 年、David Korn は Korn shell(ksh)を開発
1985 年、Richard Stallman はフリーソフト財団(FSF)設立、GNU ライセンスのフリーソフトを開発
1988 年、FSF プログラマー Brian Fox が Bourne shell をベースに Bourne-Again SHell を開発、略称 Bash。現在元も流行っている Linuxt 標準 Shell は Bash である。
1989 年、Bash v1.0 リリース
1996 年、Bash v2.0 リリース
2004 年、Bash v3.0 リリース
2009 年、Bash v4.0 リリース
2019 年、Bash v5.0 リリース
現在、多くの Linux、macOS、Windows 10 の Windows Subsystem for Linux などでは Bash は標準のシェルとして設定されている。
bash バージョン確認
bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
Copyright (C) 2007 Free Software Foundation, Inc.
# Bash をカラフルで表示
Git Bash for Mac
Git Bash インストールして Bash 綺麗に表示する
- ターミナルでコマンド実行
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/fabriziocucci/git-bash-for-mac/master/install.sh)"
- ターミナル環境設定 Pro テーマ選択
- ターミナル再起動
# Bash 5.0 について
最新の Bash5.0 は 4.0 リリースから 10 年の 2019 年にリリースされたことが話題になった。主にバグフィクスとシェル変数の更新があった。
The most significant bug fixes are an overhaul of how nameref variables resolve and a number of potential out-of-bounds memory errors discovered via fuzzing.
もっとも重要なバグフィクスは、nameref 変数の解決方法の見直しおよびファジングで発見された領域外メモリエラーの対応だ。
The most notable new features are several new shell variables: BASH_ARGV0,EPOCHSECONDS, and EPOCHREALTIME.
注目すべき新機能としては、BASH_ARGV0、EPOCHSECONDS、EPOCHREALTIME などのいくつかの新しいシェル変数だ。
mac で bash バージョンアップグレード
# bash install homebrew必要
brew install bash
# バージョン確認
bash --version
GNU bash, version 5.1.0(1)-release (x86_64-apple-darwin20.1.0)
Copyright (C) 2020 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.
# Shell の種類
今流行っている Shell バージョン Wiki リスト
- Bourne Shell(sh) (opens new window)
- Bourne Again shell(bash) (opens new window)
- C Shell(csh) (opens new window)
- Debian Almquist shell (dash) (opens new window)
- TENEX C Shell(tcsh) (opens new window)
- Korn shell(ksh) (opens new window)
- Z Shell(zsh) (opens new window)
Bash は現在一番使われている
システムに入っている Shell 一覧
cat /etc/shells
# 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
現在使っているデフォルト Shell
echo $SHELL
/bin/bash