w*r 发帖数: 2421 | 1 在Kshell里面,最近发现在script里面export variable不管用了,例子如下:
test1.sh
#! /usr/bin/ksh
VAR1=teststring
export VAR1
在ksh下面运行:
./test1.sh
echo $VAR1
显示VAR1没有任何内容,如果执行:
. ./test1.sh
echo $VAR1
会显示teststring
我的问题是这个. ./test.sh中第一个“.”起什么作用???
是不是有人改了什么ksh的设置变成这样的?以前我记得不是这样,完全不需要这个.<
space>的syntax.
哪里可以找到这样的syntax的guide? |
t*****g 发帖数: 1275 | 2 same as 'source'
【在 w*r 的大作中提到】 : 在Kshell里面,最近发现在script里面export variable不管用了,例子如下: : test1.sh : #! /usr/bin/ksh : VAR1=teststring : export VAR1 : 在ksh下面运行: : ./test1.sh : echo $VAR1 : 显示VAR1没有任何内容,如果执行: : . ./test1.sh
|
w*r 发帖数: 2421 | 3 more details please???
【在 t*****g 的大作中提到】 : same as 'source'
|
t*****g 发帖数: 1275 | 4 source or '.' a script can export variables to the parent shell.
【在 w*r 的大作中提到】 : 在Kshell里面,最近发现在script里面export variable不管用了,例子如下: : test1.sh : #! /usr/bin/ksh : VAR1=teststring : export VAR1 : 在ksh下面运行: : ./test1.sh : echo $VAR1 : 显示VAR1没有任何内容,如果执行: : . ./test1.sh
|
w*r 发帖数: 2421 | 5 got it... .
source test.sh = . test.sh
thanks!
【在 t*****g 的大作中提到】 : source or '.' a script can export variables to the parent shell.
|