<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kiririmode</author_name>
  <author_url>https://blog.hatena.ne.jp/kiririmode/</author_url>
  <blog_title>理系学生日記</blog_title>
  <blog_url>https://kiririmode.hatenablog.jp/</blog_url>
  <categories>
    <anon>bash</anon>
  </categories>
  <description>一般にシェルスクリプトでは set -eu しておけということを言われます。 -e はコマンド実行でエラーが発生した場合にそこでスクリプトの実行を終了する。 -u は誤って未定義変数を使用しようとしたときにエラーとする、という振る舞いになります。 shebang で bash 等を指定するときに、一緒に指定する方も多いのではないでしょうか。 #!/bin/bash -eu ところが、最近 set -eu したスクリプトにおいて、これってどう表現したら良いのだろうということがありました。「変数に値が定義されているか否かで処理を分岐させたい」というケースです。 簡単に書けばこんなイメージでいけるは…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fkiririmode.hatenablog.jp%2Fentry%2F20200822%2F1598070443&quot; title=&quot;set -u した状態で変数に値が定義されているか否かの分岐を表現する - 理系学生日記&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>2020-08-22 13:27:23</published>
  <title>set -u した状態で変数に値が定義されているか否かの分岐を表現する</title>
  <type>rich</type>
  <url>https://kiririmode.hatenablog.jp/entry/20200822/1598070443</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
