I have a file test
with the content
#!/bin/sh -c 'echo was called with $0'
I if i execute it it with ./test
, i would expect the OS to effectively execute
sh -c 'echo was called with $0' ./test
which to my understanding should result in was called with ./test
.
However, i get the error message
/bin/sh: 0: Illegal option -
What is the reason for this Error?
please note that i understand that there are easier ways to print the arguments, the echo
part is a stand-in for unrelated and more complex things.
Added information: cat -E test
gives me
#!/bin/sh -c 'echo was called with $0'$
$
/bin/sh
with/bin/echo
, it prints the rest of the shebang, since that works, i guess it's nothing general like lineendings but something sh-specific – keppla Aug 02 '19 at 12:47#!/usr/bin/env command --argument
fails on Linux and then there's Sven Mascheck's page about hashbang differences in different systems, with more information you ever want to know. – ilkkachu Aug 02 '19 at 13:22