Re: [PATCH 2/4] contrib/subtree: stop using `-o` to test for number of args
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 10, 2023, 23:27 UTC
- Message-ID
- <xmqqpm0hur31.fsf@gitster.g>
- In-Reply-To
- <ZU4DiTQbKyuuT55k@tanuki>
Patrick Steinhardt <ps@pks.im> writes:
Show 19 quoted lines
> On Fri, Nov 10, 2023 at 08:02:32AM +0900, Junio C Hamano wrote:
>> Jeff King <peff@peff.net> writes:
>>
>> >> # Usage: process_subtree_split_trailer SPLIT_HASH MAIN_HASH [REPOSITORY]
>> >> process_subtree_split_trailer () {
>> >> - assert test $# = 2 -o $# = 3
>> >> + assert test $# -ge 2
>> >> + assert test $# -le 3
>> > ...
>> >> - elif test $# -eq 1 -o $# -eq 2
>> >> + elif test $# -eq 1 || test $# -eq 2
>> >
>> > OK, this one is a straight-forward use of "||".
>>
>> Yes, but why not consistently use the range notation like the
>> earlier one here, or below?
>
> I opted to go for the "obvious" conversion, if there was one easily
> available, to make the diff easier to read.... and due to the limitation of "assert" we cannot do the obvious
test $# = 2 || test $# = 3
and feed it to "assert" (and for equality with $#, = and -eq would work equally fine, and = is much more readable, by the way).
OK, then.