In my Bash script, I'm generating a string which contains a series of commands. Some of these commands are references to a function defined within this script. That is:
function myfunc() {
...}
}
cmds=`echo "echo hello"; echo myfunc` # contrived, but you get the idea
bash $cmds
Now, running the commands by invoking a new Bash script doesn't work - the function myfunc
isn't defined.
Is there a way around this? Either by making the function global somehow, or by making those commands run within the current shell?