是!
$cat a.sh echo "$@" echo $@
我们来运行吧:
$./a.sh 2 "3 4" 5 2 3 4 5 # output for "$@" 2 3 4 5 # output for $@ -> spaces are lost!
正如您所看到的,使用$@会使参数在用作参数时“丢失”某些内容.有关详细说明,请参见-for-example- I just assigned a variable,but echo $variable shows something else.
从GNU Bash manual –> 3.4.2 Special Parameters开始:
@
($@) Expands to the positional parameters,starting from one. When the expansion occurs within double quotes,each parameter expands to a separate word. That is,“$@” is equivalent to “$1” “$2” …. If the double-quoted expansion occurs within a word,the expansion of the first parameter is joined with the beginning part of the original word,and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters,“$@” and $@ expand to nothing (i.e.,they are removed).