<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>BioErrorLog</author_name>
  <author_url>https://blog.hatena.ne.jp/BioErrorLog/</author_url>
  <blog_title>BioErrorLog Tech Blog</blog_title>
  <blog_url>https://www.bioerrorlog.work/</blog_url>
  <categories>
    <anon>Linux</anon>
    <anon>shell</anon>
  </categories>
  <description>パイプ処理の終了ステータスを取得する方法をまとめます。 はじめに パイプ処理の終了ステータスを取得する PIPESTATUS を参照する方法 set -o pipefail を利用した方法 おわりに 参考 はじめに パイプ処理の終了ステータスを取得($?)すると、デフォルトでは一番最後のコマンドの終了ステータスのみが取得されます。 #!/bin/bash exit 1 | exit 2 | exit 0 echo $? # 出力: 0 パイプ内コマンドの終了ステータスはマスクされてしまうので、パイプ内の異常終了を検知したいときなどに不都合です。 今回は、パイプ処理内の各コマンドの終了ステータス…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.bioerrorlog.work%2Fentry%2Fhandle-pipe-exit-status&quot; title=&quot;パイプ処理の終了ステータスを取得する | Linux shell - BioErrorLog Tech Blog&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>https://cdn-ak.f.st-hatena.com/images/fotolife/B/BioErrorLog/20210612/20210612123452.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-06-12 12:35:52</published>
  <title>パイプ処理の終了ステータスを取得する | Linux shell</title>
  <type>rich</type>
  <url>https://www.bioerrorlog.work/entry/handle-pipe-exit-status</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
