Christian Couder <christian.couder@xxxxxxxxx> 于2021年4月1日周四 下午3:22写道: > > On Wed, Mar 31, 2021 at 12:05 PM ZheNing Hu via GitGitGadget > <gitgitgadget@xxxxxxxxx> wrote: > > > > From: ZheNing Hu <adlternative@xxxxxxxxx> > > > > When we use subprocess to run a shell-script, if we have any > > Maybe: s/subprocess/a subprocess/ > > > args, git will add extra $@ to the end of the shell-script, > > This can pass positional parameters correctly, But if we just > > want to use some of these passed parameters, git will still > > add an extra "$@", which contains all positional parameters we > > passed. This does not meet our expectations. > > I am not sure explaining things using $@ is the best way to make this > as clear as possible. I don't have a clear alternative right now > though. > > > E.g. our shell-script is: > > "echo \"\$1\"" > > and pass $1 "abc", > > Maybe: s/pass $1 "abc"/we pass "abc" as $1/ > > > git will change our script to: > > "echo \"\$1\" \"$@\"" > > Where will "abc" appear then? > > > The positional parameters we entered will be printed > > repeatedly. > > If you take us passing "abc" in $1 as an example, then I think it's a > good idea to show us the result of that. > > > So let add a new `shell_no_implicit_args` > > Maybe: s/`shell_no_implicit_args`/`shell_no_implicit_args` flag/ > Thanks for these grammar corrections. > > to `struct child_process`, which can suppress the > > joining of $@ if `shell_no_implicit_args` is set to 1, > > this will allow us to use only few of positional args > > in multi-parameter shell script, instead of using all > > of them. > > I think our goal is more to have each argument we pass be passed just once. More accurately, we only want those explicit positional parameters to be replaced. But Junio probably thinks it's OK to put on a layer of "sh -c" to "absorb" the "$@". I think it works, but it may cause some trouble for users. -- ZheNing Hu