Answers:
它是当前的shell脚本或函数参数,单独引用。
man bash
说:
@
从1开始扩展到位置参数。当扩展发生在双引号内时,每个参数都会扩展为单独的单词。那是,"$@"
相当于"$1" "$2" ...
给出以下脚本:
#!/usr/bin/env bash
function all_args {
# repeat until there are no more arguments
while [ $# -gt 0 ] ; do
# print first argument to the function
echo $1
# remove first argument, shifting the others 1 position to the left
shift
done
}
echo "Quoted:"
all_args "$@"
echo "Unquoted:"
all_args $@
这在执行时发生:
$ ./demo.sh foo bar "baz qux"
Quoted:
foo
bar
baz qux
Unquoted:
foo
bar
baz
qux
\$@
在man bash
。你需要摆脱美元的性格。