Re: [PATCH] test-lib: allow short options to be stacked
- From
Matheus Tavares <matheus.bernardino@usp.br>
- Date
- Mar 21, 2020, 17:27 UTC
- Message-ID
- <20200321172752.3268-1-matheus.bernardino@usp.br>
- In-Reply-To
- <xmqqsgi29um6.fsf@gitster.c.googlers.com>
On Sat, Mar 21, 2020 at 1:53 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Matheus Tavares <matheus.bernardino@usp.br> writes:
>
> > +parse_option () {
> > + local opt="$@"
>
> I do not think there is any context in which var="$@" makes sense in
> shell script (var="$*" is understandable, though).
>
> Did you mean opt=$1 here?Right, it should be $1. Thanks.
Show 6 quoted lines
> > +# Parse options while taking care to leave $@ intact, so we will still > > +# have all the original command line options when executing the test > > +# script again for '--tee' and '--verbose-log' below. > > The phrase "below" no longer makes much sense after moving lines > around, does it?
Oh, I thought "below" referred to the later usage of $@ (when --tee or --verbose-log are set). I.e. not the parsing section we moved up, but this one:
elif test -n "$tee"
then
...
(GIT_TEST_TEE_STARTED=done ${TEST_SHELL_PATH} "$0" "$@" 2>&1;Maybe change "below" for "later in the code"?
Show 20 quoted lines
> > +store_arg_to= > > +prev_opt= > > +for opt > > +do > > + if test -n "$store_arg_to" > > + then > > + eval $store_arg_to=\$opt > > + store_arg_to= > > + prev_opt= > > + continue > > + fi > > + > > + case "$opt" in > > + --*) > > + parse_option "$opt" ;; > > + -?*) > > + # stacked short options must be fed separately to parse_option > > Are you calling concatenated short options, e.g. "-abc", as > "stacked"? It sounds like a very unusual phrasing, at least to me.
Yeah, I wasn't really sure about the naming for this. Thanks, "concatenated" (or "bundled", as Peff suggested in another reply) does sound better.