由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - 一个有关shell script export variable的问题
相关主题
shell script和variable index包子求助一道题 Perl (转载)
bash 中如何将命令的返回值存到变量中?求助看你是不是linux高手? dpkg: version 'uname -r' has bad syntax
shell read怎么一次read很多变量?有vim script 高手吗?
Re: 有什么比较好的断点续传的 ftp/sftp 软件? (转载)关于 gcc 和 g++ 的问题 (转载)
偶也文个vi的问题C -> Assembly
对了,关于debuggernasty perl syntax minute issues
比较emacs flymake和vim codecheckhow to change the color of c language keyword in vi ?
vim text alignmentHex byte string syntax in perl please
相关话题的讨论汇总
话题: var1话题: export话题: script话题: ksh话题: variable
进入Linux版参与讨论
1 (共1页)
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.
1 (共1页)
进入Linux版参与讨论
相关主题
Hex byte string syntax in perl please偶也文个vi的问题
小白问:awk里面引用变量为啥有的加'$'有的不加?对了,关于debugger
推荐一个online bookmarks?比较emacs flymake和vim codecheck
请教 GNU Screen display 的问题vim text alignment
shell script和variable index包子求助一道题 Perl (转载)
bash 中如何将命令的返回值存到变量中?求助看你是不是linux高手? dpkg: version 'uname -r' has bad syntax
shell read怎么一次read很多变量?有vim script 高手吗?
Re: 有什么比较好的断点续传的 ftp/sftp 软件? (转载)关于 gcc 和 g++ 的问题 (转载)
相关话题的讨论汇总
话题: var1话题: export话题: script话题: ksh话题: variable