我可以在sh(Bourne shell)中导出函数吗?(How to export a function in Bourne shell?)
是否可以在Bourne shell(sh)中导出函数?
这个问题的答案表明如何对bash , ksh和zsh这样做,但没有人说sh是否支持它。
如果sh肯定不允许,我不会再花时间去搜索它。
Is it possible to export a function in Bourne shell (sh)?
The answers in this question indicate how to do so for bash, ksh and zsh, but none say whether sh supports it.
If sh definitely does not allow it, I won't spend any more time searching for it.
最满意答案
不,这是不可能的。
用于导出的POSIX规范非常明确,它只支持变量。 在更新的shell中用于此目的的typeset和其他扩展只是 - 扩展 - 在POSIX中不存在。
No, it is not possible.
The POSIX spec for export is quite clear that it only supports variables. typeset and other extensions used for the purpose in more recent shells are just that -- extensions -- not present in POSIX.
更多推荐
发布评论