Re: [PATCH v2 0/8] git-submodule.sh: improve parsing of options
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 11, 2024, 00:02 UTC
- Message-ID
- <xmqqikrrjdds.fsf@gitster.g>
- In-Reply-To
- <CAOfFamkEmJgUUj8C_TGbjgKs35vSBzNCDpLvK+utqnTtxd5iHQ@mail.gmail.com>
Roy E <royeldar0@gmail.com> writes:
Show 7 quoted lines
>> I am assuming (but I don't use "git submodule" very often, so my >> assumption may be way off) that there is no such variable we need to >> pass, but if not, we may need to reconsider and use the "variable has >> only value of the option" for at least some of them. > > Indeed, there aren't such variables; all of the options which take > arguments have exactly one argument.
Just to make sure we are on the same page,
--foo "hello world"
is an example of an option "foo" that takes exactly one argument, a string which happens to have a whitespace in it, and is an example for which "variable has the dash-dash option, equals, and its value" pattern would not work well.
If we pass an argument that is an end-user provided message or is a project controlled pathname, we are likely to be in the same situation.
If we can pass it as
--foo="hello world"
then we are safe, as we can do
foo="--foo=hello world"
... later ...
git cmd ${foo:+"$foo"}