は、それがサブプロセスに渡されますかどうかを決定します。シェル関数の場合、これは実際にはサブプロセスが別のシェルである場合にのみ重要です。
$ exportedfunc() { echo "This is the exported function"; }
$ export -f exportedfunc
$ nonexportedfunc() { echo "This is the non-exported function"; }
$ bash # create a subshell to see which functions it inherits
$ PS1='\$\$ ' # set a different prompt so we can tell the subshell ($$) from the parent shell ($)
$$ exportedfunc # This'll work, because the parent shell exported the function
This is the exported function
$$ nonexportedfunc # This won't work because this function was not exported to subprocesses
bash: nonexportedfunc: command not found
$$ exit # back to the parent shell, where both functions are defined
$ exportedfunc
This is the exported function
$ nonexportedfunc
This is the non-exported function
私はすべての機能が自動的にエクスポートすることが原因となる任意のシェルの設定を知らない:ここではイラストです。暗黙的にサブシェルを作成した場合(たとえば、カッコ内にいくつかのコマンドを入れて)、をエクスポートするかどうかは、すべてを継承します。
@ Jonathan Leffler:質問を編集していただきありがとうございます。上の引用符を示す黄色のブロックを作る方法を教えてください。 stackoverflowのmarkdown命令でフォーマットを見つけようとしましたが、残念ながら何がどこにあるのかわかりませんでした。どうもありがとうございました。 – mora