- 论坛徽章:
- 145
|
回复 jason680
. ./test2.sh这样使用不能传递参数,我的程序中还要给其传递参数,所以只能./tes ...
whpu000625 发表于 2011-04-22 15:04 ![]()
$ cat t.sh- #!/bin/bash
- echo ">>>[t.sh] start ..."
- AA=""
- export AA
- export qq="qqqq"
- echo "qq=$qq"
- echo "pg=$0,arg1=$1,arg2=$2,arg3=$3"
- . ./test2.sh $2 $1
- echo "======test======="AA=$AA
- echo "<<<[t.sh] end"
复制代码 $ cat test2.sh- #!/bin/sh
- echo ">>>[test2.sh] start ..."
- echo "qq=$qq"
- echo "pg=$0,arg1=$1,arg2=$2,arg3=$3"
- . ./test1.sh
- test
- echo "=======test2======" AA=$AA
- echo "<<<[test2.sh] end"
复制代码 嗯,我这都没问题...除了$0外...
$ ./t.sh abc 123 xxx
>>>[t.sh] start ...
qq=qqqq
pg=./t.sh,arg1=abc,arg2=123,arg3=xxx
>>>[test2.sh] start ...
qq=qqqq
pg=./t.sh,arg1=123,arg2=abc,arg3=
=======test2====== AA=aaaa
<<<[test2.sh] end
======test=======AA=aaaa
<<<[t.sh] end
$
注:传给test2.sh参数1,2交换位置 |
|