我正在写一个调用在父shell中声明的函数的bash脚本,但它不起作用。Bash - 如何调用在父shell中声明的函数?
例如:
$ function myfunc() { echo "Here in myfunc" ; }
$ myfunc
Here in myfunc
$ cat test.sh
#! /bin/bash
echo "Here in the script"
myfunc
$ ./test.sh
Here in the script
./test.sh: line 4: myfunc: command not found
$ myfunc
Here in myfunc
正如你可以看到脚本./test.sh
是无法调用的函数myfunc
,有没有一些方法,使这种功能的脚本可见?
现在,我做*不*知道。 – 2010-02-04 12:36:43
@ Andrew:对!有一些答案是无法改进的。 – 2010-02-05 20:46:31
这些事情应该更好地记录 – erjoalgo 2013-10-12 23:17:48