如何在Bourne shell中导出函数? [英] How to export a function in Bourne shell?

查看:45
本文介绍了如何在Bourne shell中导出函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Bourne shell(sh)中导出函数?

Is it possible to export a function in Bourne shell (sh)?

此问题中的答案表示如何对 bash执行此操作 ksh zsh ,但没有人说 sh 是否支持它.

The answers in this question indicate how to do so for bash, ksh and zsh, but none say whether sh supports it.

如果 sh 绝对不允许这样做,我将不再花费更多时间进行搜索.

If sh definitely does not allow it, I won't spend any more time searching for it.

推荐答案

否,这不可能.

导出的POSIX规范很清楚,它仅支持变量. typeset 和其他在最新的shell中用于此目的的扩展名-扩展名-在POSIX中不存在.

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.

这篇关于如何在Bourne shell中导出函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆