我可以在sh(Bourne shell)中导出函数吗?(How to export a function in Bourne shell?)

编程入门 行业动态 更新时间:2024-10-26 08:24:43
我可以在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.

更多推荐

本文发布于:2023-07-09 14:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1086993.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   Bourne   sh   shell   function

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!