「Transwiki:Bash Shell Scripting」の版間の差分

削除された内容 追加された内容
Fu7mu4 (トーク | 投稿記録)
Fu7mu4 (トーク | 投稿記録)
806 行
** 通常のBash変数がサブシェル内で修正された場合、その変更は親のシェルからは見えません。
** この挙動は関数でも同じで、通常のBash変数にもあてはまる。
* 関数呼び出しは、サブシェルで継承された実行ではありません。
* Function-calls are not inherently run in subshells.
** 関数内での変数の修正は通常、関数を呼び出したコードから ''見え''ます。
* 環境にエクスポートされた Bash 変数のスコープは、それを包むシェル、そのシェルのサブシェル、そのシェルの子プロセスです。
* Bash variables that are exported into the environment are scoped to the shell that contains them, including any subshells ''or child processes'' in that shell.
** ビルトインの<tt>export</tt> コマンドは環境に変数をエクスポートするために使用できます。(これ以外にも方法はあるがこれが一番通常の方法です。)
** The <tt>export</tt> built-in command can be used to export a variable into the environment. (There are other ways as well, but this is the most common way.)
** エクスポートされていない変数はその子プロセスで見えないことです。特に親シェルや親プロセスでは見えません。
** They differ from non-exported variables only in that they are visible to child processes. In particular, they are still not visible to parent shells or parent processes.
* その他のプログラムのような、外部のBashスクリプトは、子プロセスとして実行します。ビルトインコマンドの <tt>.</tt> や <tt>source</tt> はそのスクリプトを内部で実行します。この場合、サブシェルのように継承しません。
* External Bash scripts, like other external programs, are run in child processes. The <tt>.</tt> or <tt>source</tt> built-in command can be used to run such a script internally, in which case it's not inherently run in a subshell.
 
To this we now add: