Hello,
As the interface is not specified, would it make sense to:
* add a prefix (use BASH_FUNCTION_foo instead of foo for exported
function foo);
* still expand the variable if it matches the 'exported function'
pattern.
The first point would reduce the probability of a clash with
a user variable:
foo() {
echo Executing function "$@"
}
foo="aa"
export -f foo
export foo
bash -c foo
# OK
bash -c 'echo $foo'
# OK as well
bash -c env
# In fact the environment variable is set twice, I didn't know it was event
possible
dash -c 'echo $foo'
# Dash find the second one: () { echo Executing function "$@" }
The second (more important) point would allow a variable to begin with
"() {}" or similar:
# I'm not aware of the function export feature
# or x comes from somewhere else:
$ x="() {}" bash -c 'echo $x' 2>/dev/null
$ x="() {}" dash -c 'echo $x' 2>/dev/null
() {}
--
Gabriel