- 论坛徽章:
- 145
|
本帖最后由 jason680 于 2014-08-02 22:45 编辑
回复 10# iLRainyday
$ set -x; ./x a_${count}=filename; set +x
+ ./x a_0=filename
++ set -v
echo $1
++ echo a_0=filename
a_0=filename
+ set +x
$ cat x
set -x
set -v
echo $1
the ./x(eval) didn't get the ${count}, but get the 0
./x a_${count}=filename
1. first time, shell get the ./x command, and expand the variable for ./x
2. ./x only get the 0, and didn't know the ${count}
./x a_0=filename
>>...在使用eval的时候,也就是第二次进行命令行处理的时候,对等号左端进行了expansion。这和你之前所讲到等号左端不进行处理又矛盾了啊~
eval a_${count}=filename
1. first time, shell get the eval command, and expand the variable for eval
2. eval only get the 0, and didn't know the ${count}
eval a_0=filename
3. eval function will send a_0=filename to assign variable again.
注: 等号左端不进行处理
指的是赋值语句中Left=Right 时, Left 不展开....
eval .... (shell第一次处理eval ...时,并不是赋值语句...)
|
|