If your sh
is bash
, then the Bash man page has some info:
-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.
Before you get a chance to access $@
, Bash interprets the -c
and will pass the subsequent arguments through as parameters to the sub shell. This means $0
will be the next value passed, which is 4 (essentially $@
and $0
are the same at this point because there is only one value).
If you run the sh
with -v
you will see slightly more about what is happening:
$ git testing 1 4
echo $@
4
So the echo $@
gets only 4 in its arguments. The -c
will create a sub shell, and pass $@
though. Remember this contains only 4 now. This is where you are losing the 1.