LoginSignup
2
2

More than 5 years have passed since last update.

パイプのひとつ前の終了ステータスを取得することはできますか?

Posted at

Linux のパイプラインで, ひとつ前のコマンドの終了ステータスを取得することってできるんでしょうか.

例えば, 以下のような場合, ruby スクリプトが 0 以外のステータスで終了した場合, それを通知する, なんてことがやりたいです.

$ ruby script.rb | notify_if_error

できなければ, こういう方法もあるとは思いますが...

$ notify_if_error --cmd "ruby script.rb"

でも前者の方がわかりやすいように思います.
どなたか教えてください.

2
2
2

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
2
2