# cd /home/xyz/tmp
# ls
etc etc.tar.bz2
# a=*
# echo $a
etc etc.tar.bz2
# echo "$a"
*
#
# unset a
# a="*"
# echo $a
etc etc.tar.bz2
# echo "$a"
*
#
在bash的解析过程中, 双引号可以阻止词的拆分。 原本以为a=*, 会被扩展成a="etc etc.tar.bz2", 但是其实在执行过程中, 并没有被扩展。
原因: man bash
name=[value]
If value is not given, the variable is assigned the null string. All
values undergo tilde expansion, parameter and variable expansion, com-
mand substitution, arithmetic expansion, and quote removal (see EXPAN-
SION below). If the variable has its integer attribute set, then value
is evaluated as an arithmetic expression even if the $((...)) expansion
is not used (see Arithmetic Expansion below). Word splitting is not
performed, with the exception of "$@" as explained below under Special
Parameters. Pathname expansion is not performed. Assignment state-
ments may also appear as arguments to the alias, declare, typeset,
export, readonly, and local builtin commands.
阅读(1239) | 评论(0) | 转发(0) |