Saturday, April 9, 2022

[SOLVED] How to export a function in Bourne shell?

Issue

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.


Solution

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.



Answered By - Charles Duffy
Answer Checked By - Mary Flores (WPSolving Volunteer)