实例:
1) source1.sh
#!/bin/sh
echo "--------------------------------"
var1=var1v
source source2.sh
echo $var1
echo $var2
echo "---------------------------------"
sh source3.sh
echo $var1
echo $var3
echo "----------------------------------"
export var=varv
sh source4.sh
echo $var
echo "----------------------------------"
echo "--------------------------------"
var1=var1v
source source2.sh
echo $var1
echo $var2
echo "---------------------------------"
sh source3.sh
echo $var1
echo $var3
echo "----------------------------------"
export var=varv
sh source4.sh
echo $var
echo "----------------------------------"
2) source2.sh
#!/bin/sh
echo start suorce2
echo $var1
var1=var1insource2
var2=var2v
echo $var1
echo $var2
echo end source2
echo start suorce2
echo $var1
var1=var1insource2
var2=var2v
echo $var1
echo $var2
echo end source2
3) source3.sh
#!/bin/sh
echo start source3
echo $var1
var1=var1insource3
var3=var3v
echo $var1
echo $var3
echo end source3
echo start source3
echo $var1
var1=var1insource3
var3=var3v
echo $var1
echo $var3
echo end source3
4) source4.sh
#!/bin/sh
echo start source4
echo $var
var=varinsource4
echo $var
echo end source4
echo start source4
echo $var
var=varinsource4
echo $var
echo end source4
结果:
结论: http://www.cnblogs.com/itech/archive/2009/09/22/1571896.html
完!