shell调用其它脚本的函数

bash

shellname.sh

1
2
3
4
5
6
7
8
9
10
test_func()
{
local p1="$1"
if [ "$p1" == "" ]; then
echo "1 null"
return 1
fi
echo "1 ${p1}"
return 0
}
1
2
3
4
5
6
7
8
. ./shellname.sh

res=`test_func "123"`
if [ $? != "0" ]; then
echo "fatal"
else
echo "ok"
fi