From: Junio C Hamano <gitster@pobox.com>
To: Matheus Tavares <matheus.bernardino@usp.br>
Cc: git@vger.kernel.org, "SZEDER Gábor" <szeder.dev@gmail.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] test-lib: allow short options to be stacked
Date: Fri, 20 Mar 2020 21:53:21 -0700 [thread overview]
Message-ID: <xmqqsgi29um6.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <48c28683412e3e0803d4c7189a6d66daddcdc580.1584759277.git.matheus.bernardino@usp.br> (Matheus Tavares's message of "Sat, 21 Mar 2020 00:07:05 -0300")
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?
> +# 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?
> +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.
> + for c in $(echo "${opt#-}" | sed 's/./& /g')
> + do
> + parse_option "-$c"
> + done
> + ;;
> + *)
> + echo "error: unknown test option '$opt'" >&2; exit 1 ;;
> + esac
>
> prev_opt=$opt
> done
I am personally not very enthused (the line counts vs benefit does
not feel so great), but as long as it works correctly and
maintainable, I won't complain too much.
next prev parent reply other threads:[~2020-03-21 4:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-21 3:07 [PATCH] test-lib: allow short options to be stacked Matheus Tavares
2020-03-21 4:53 ` Junio C Hamano [this message]
2020-03-21 17:27 ` Matheus Tavares
2020-03-21 6:26 ` Jeff King
2020-03-21 18:50 ` Matheus Tavares Bernardino
2020-03-22 6:49 ` Jeff King
2020-03-22 8:14 ` SZEDER Gábor
2020-03-21 18:57 ` Junio C Hamano
2020-03-21 8:55 ` Johannes Sixt
2020-03-21 18:55 ` Matheus Tavares Bernardino
2020-03-21 20:11 ` Junio C Hamano
2020-03-21 19:57 ` [PATCH v2] test-lib: allow short options to be bundled Matheus Tavares
2020-03-21 20:07 ` Junio C Hamano
2020-03-21 22:42 ` Matheus Tavares Bernardino
2020-03-22 15:58 ` [PATCH v3] " Matheus Tavares
2020-03-23 20:18 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqsgi29um6.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=matheus.bernardino@usp.br \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).