【发布时间】:2012-09-01 02:55:08
【问题描述】:
在许多 SO 问题和 bash 教程中,我看到我可以通过两种方式访问 bash 脚本中的命令行参数:
$ ~ >cat testargs.sh
#!/bin/bash
echo "you passed me" $*
echo "you passed me" $@
结果:
$ ~> bash testargs.sh arg1 arg2
you passed me arg1 arg2
you passed me arg1 arg2
$* 和 $@ 有什么区别?
什么时候用前者,什么时候用后者?
【问题讨论】:
-
IntelliJ 中的静态分析将
echo "something $@"视为错误
标签: bash command-line-arguments