I have the following code
func1(){
#some function thing
function2(){
#second function thing
}
}
and I want to call
Limit the scope of the inner function
Use function defined with parenthesis () instead of braces {}:
f() (
g() {
echo G
}
g
)
# Ouputs `G`
f
# Command not found.
g
Parenthesis functions are run in sub-shells, which have the same semantics of () vs {}, see also: Defining bash function body using parenthesis instead of braces
This cannot be used if you want to:
exitcdas those are lost in the created sub-shell.
See also: bash functions: enclosing the body in braces vs. parentheses