0

This question already has an answer here:

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'$
$

marked as duplicate by Jesse_b, ilkkachu, filbranden, msp9011, Andy Dalton Aug 2 at 15:09

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.