「Transwiki:Bash Shell Scripting」の版間の差分
削除された内容 追加された内容
M →サブシェル |
M →サブシェル |
||
714 行
出力内容: <pre>/
/
/home
/</pre>
{{Transwiki:Bash Shell Scripting/tip|もしあなたのスクリプトが与えられたコマンドを実行する前に現在ディレクトリを変更する必要がある場合、可能であればサブシェルはよいアイディアです。サブシェルを使用しない場合、スクリプトを読み間常に現在ディレクトリを追跡しなければなりません。(代替方法としては、ビルトインコマンドの <tt>pushd</tt> と<tt>popd</tt>があり、類似した効果が得られます。)}}
サブシェル内の<tt>exit</tt>ステートメントはそのサブシェルだけを終了させます。また例を挙げます。:
<source lang="bash">#!/bin/bash
723 行
</source>
Like in a script as a whole, <tt>exit</tt> defaults to returning the exit status of the last-run command, and a subshell that does not have an explicit <tt>exit</tt> statement will return the exit status of the last-run command.
|