You must use "$@"
instead of $*
:
exec ./mysh1 "$@"
That's the right way to expand all positional arguments as separated words.
When you use $*
, all positional arguments was concatenated in to one long string, with the first value of IFS
as separator, which default to a whitespace, you got A B 2 C
.
Now, because you use $*
without double quote (which can lead to security implications and make your script choked), the shell perform split+glob
on it. The long string you got above was split into four words, A
, B
, 2
and C
.
Therefore, you actually passed four arguments to mysh1
instead of three.
"$@"
instead of$*
, note the quotes. See also: http://unix.stackexchange.com/q/41571/38906 – cuonglm Dec 10 '15 at 03:15./mysh0
is an intermediate script that I do not own. – jvliwanag Dec 10 '15 at 03:22mysh0
, because it decided how to pass argument tomysh1
. – cuonglm Dec 10 '15 at 03:27