Re: [PATCH v5 1/2] [GSOC] run-command: add shell_no_implicit_args option
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Apr 1, 2021, 07:22 UTC
- Message-ID
- <CAP8UFD2tb6Fca58YPiFejqGKm3Mu+NaMA8YU3HQj+c2L-AH-Yw@mail.gmail.com>
- In-Reply-To
- <4c59cab53a0d9bb7c9cccfaf5544ae5c904bb2ba.1617185147.git.gitgitgadget@gmail.com>
On Wed, Mar 31, 2021 at 12:05 PM ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com> wrote:
> > From: ZheNing Hu <adlternative@gmail.com> > > When we use subprocess to run a shell-script, if we have any
Maybe: s/subprocess/a subprocess/
Show 5 quoted lines
> 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/
Show 5 quoted lines
> 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.