What problem are you trying to solve? If you tell us that, we can guide you to some better solutions.
There are numerous issues here, but the most important are: 1) Calling a shell via \! invokes an entirely new process: there is no link to the parent or grandparent process 2) The run-bash-function must be declared before being called, so that bash code was never going to work anyway. In other words, this is valid: run-bash-function() { echo "Here we are"; } run-bash-function This version is not: run-bash-function run-bash-function() { echo "Here we are"; } Cheers, Greg