【发布时间】:2010-02-04 12:07:12
【问题描述】:
我正在编写一个调用父 shell 中声明的函数的 bash 脚本,但它不起作用。
例如:
$ 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,有什么方法可以使该函数对脚本可见吗?
【问题讨论】: