<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>kwbtblog</author_name>
  <author_url>https://blog.hatena.ne.jp/kwbtblog/</author_url>
  <blog_title>新しいことにはウェルカム</blog_title>
  <blog_url>https://www.kwbtblog.com/</blog_url>
  <categories>
    <anon>Bash</anon>
    <anon>Linux</anon>
    <anon>Shell Script</anon>
    <anon>ShellScript</anon>
    <anon>シェルスクリプト</anon>
  </categories>
  <description>シェルスクリプトを使っていて、スクリプトが長く見づらくなってきたので、関数でまとめようとしました。 しかし、シェルスクリプトの関数の戻り値は、他のプログラム言語の関数の戻り値と違っていて、同じように使うには工夫が必要でした。 ただ、ちょっとトリッキーな使い方になってしまったので、自分用に使い方をメモしておこうと思います。 シェルスクリプトの関数の問題点 関数はreturnで戻り値を返せるのですが、返せるのは整数値1つのみです。 戻り値というより、関数が成功したか否かを示す終了ステータス値として使用され、一般的に関数が成功した場合は「0」を返すようにします。 では、情報を関数の呼び出し元に渡すに…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fwww.kwbtblog.com%2Fentry%2F2022%2F11%2F09%2F154502&quot; title=&quot;シェルスクリプトの関数で戻り値を使う - 新しいことにはウェルカム&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/k/kwbtblog/20221029/20221029072949.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2022-11-09 15:45:02</published>
  <title>シェルスクリプトの関数で戻り値を使う</title>
  <type>rich</type>
  <url>https://www.kwbtblog.com/entry/2022/11/09/154502</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
