sh -c in shebang

sh -c in shebang

test我有一个包含内容的文件

#!/bin/sh -c 'echo was called with $0'

如果我用 执行它./test,我希望操作系统能够有效地执行

sh -c 'echo was called with $0' ./test

据我了解应该导致was called with ./test

但是,我收到错误消息

/bin/sh: 0: Illegal option -

这个错误的原因是什么?

请注意,我知道有更简单的方法来打印参数,该echo部分是不相关且更复杂的事物的替代品。

补充信息:cat -E test给我

#!/bin/sh -c 'echo was called with $0'$
$

相关内容