LoginSignup
9
6

More than 5 years have passed since last update.

bash 書くとき先頭に設定する options

Posted at

set -o errexit

0 以外のステータスで終了したら即終了

set -o nounset

未定義の変数を参照するとエラーメッセージが出る。

set -o pipefail

errexit だと pipe の左側がエラーじゃなくても pipe 先の処理が走ってしまう。pipe で処理が失敗したら確実にエラーにする。

error はこちらの trap を用意した方が便利だと思う

9
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
6