Re: [PATCH v4] [GSOC]trailer: pass arg as positional parameter
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- Apr 2, 2021, 02:08 UTC
- Message-ID
- <CAOLTT8TDiAxJh3xn1WdF5mTtbA29nTSP0ohyi6aqGds8p6vd1A@mail.gmail.com>
- In-Reply-To
- <xmqqlfa13hw3.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2021年4月2日周五 上午3:49写道:
Show 34 quoted lines
> > ZheNing Hu <adlternative@gmail.com> writes: > > >> The way to do the same without an extra script on disk is for you to > >> use sh-c yourself. > >> > >> .cmd = sh -c 'echo 123' > > > > This is indeed a viable solution, But the extra "sh -c" seems to put an > > unnecessary burden on the user. > > Nobody forces you to write long script in the configuration file. > In fact, the "find author from history" is so useful that I'd think > people have an alias or a script in ~/bin/ already for their own > interactive use. E.g. > > $ cat ~/bin/git-who > #!/bin/sh > git log -1 --format="%an <%ae>" --author="$1" > $ cat ~/bin/git-one > #!/bin/sh > git show -s --pretty=reference "$1" > > and with them: > > trailer.key.cmd = git who > > that is internally wrapped into > > sh -c 'git who "$@"' > > and fed "gitster@" as the first parameter when "--trailer=key:gitster@" > is given would work just fine. >
Okay, now I get it. This allows us to run some common scripts or just use "sh -c". I might need some additional tests to illustrate those changes made by using '.cmd'.
Show 8 quoted lines
> > Sometimes I wonder, why not recommend using environment variables > > like $ARG? > > I am also fine with that; when we discovered the design flaw of > .command, I think I suggested either would make a viable choice. > The only downside is that it would squat on a good name $ARG and > forbids end-users from using the symbol for other purpose, but as > long as the application is limited in scope, that would be fine.
I agree with you. This may indeed be a minor drawback.
Thanks, Junio.
-- ZheNing Hu