Given ./mysh0:#!/bin/bashexec ./mysh1 $*And ./mysh1:#!/bin/bashecho $1echo $2echo $3How do I call mysh0 such that the arguments to mysh1 and what's eventually printed are A, B 2 and C?Calling this as ./mysh0 A B 2 C does not work.
Escape shell arg from one script to another
bash;shell script;quoting
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.