For example, the following commands doesn't work. I wonder how to work around it, thanks.
[liuke@liuke-mbp ~]$ function showxx() { echo xx; }
[liuke@liuke-mbp ~]$ showxx
xx
[liuke@liuke-mbp ~]$ cat a.bash
#!/bin/bash
showxx
[liuke@liuke-mbp ~]$ ./a.bash
./a.bash: line 2: showxx: command not found
You need to export your functions. You can either export everything when it's created (my preference) with set -a
, or you can export the functions individually with export -f showxx
. Either will put it into the environment, and child shells will be able to pick them up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With