Skip to main content
2 of 5
deleted 2 characters in body
Ijaz Ahmad
  • 7.4k
  • 7
  • 35
  • 46

From man sh

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned
             to the positional parameters, starting with $0

It means your command should be like this:

 sh -c 'echo $0' foo 
 foo

Similarly:

sh -c 'echo $0 $1' foo bar
foo bar
Ijaz Ahmad
  • 7.4k
  • 7
  • 35
  • 46