$ bash -c 'echo "0 is $0 1 is $1"' abc def
0 is abc 1 is def
$ echo 'echo "0 is $0 1 is $1"' > bashtest
$ bash bashtest abc def
0 is bashtest 1 is abc
第二次运行相当于如果我用shebang将bash测试变成shellscript然后直接运行它......
基本上我想知道为什么 abc 并不总是$1
. 它$0
在运行时变为bash -c
.