<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>hibariya</author_name>
  <author_url>https://blog.hatena.ne.jp/hibariya/</author_url>
  <blog_title>ESM アジャイル事業部 開発者ブログ</blog_title>
  <blog_url>https://blog.agile.esm.co.jp/</blog_url>
  <categories>
    <anon>TIL</anon>
    <anon>shell</anon>
  </categories>
  <description>シェルスクリプトで途中のコマンドが失敗したら直ちに実行を中断してほしいことがあります。 事前に set -e しておけば、コマンドが失敗したとき (non-zero で終了したとき) にスクリプト自体が異常終了します。 #!/bin/sh set -e false # ここで中断される echo ':(' # 実行されては困る処理 sh や bash も -e を同じように解釈するので、#!/bin/sh -e というように shebang に書くこともできます。 反対に set -o errexit というやや冗長な書き方もあります。 次のような箇所では、コマンドが non-zero を返し…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.agile.esm.co.jp%2Fentry%2F2016%2F05%2F18%2F210500&quot; title=&quot;`set -e` で、コマンドが失敗したときシェルスクリプトの実行を中断する - ESM アジャイル事業部 開発者ブログ&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></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2016-05-18 21:05:00</published>
  <title>`set -e` で、コマンドが失敗したときシェルスクリプトの実行を中断する</title>
  <type>rich</type>
  <url>https://blog.agile.esm.co.jp/entry/2016/05/18/210500</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
