Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

set -o errexit

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

set -o nounset


set -o pipefail

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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away