Re: [PATCH] completion: fix incorrect bash/zsh string equality check
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 8, 2021, 22:16 UTC
- Message-ID
- <xmqqh7dri2m1.fsf@gitster.g>
- In-Reply-To
- <CAMmwyQpP0m6dTdC-L9abZqk9nJkcYy=j4_s0+EdGDr__pykeXQ@mail.gmail.com>
Robert Estelle <robertestelle@gmail.com> writes:
Show 11 quoted lines
> On Fri, Oct 8, 2021 at 1:50 PM Junio C Hamano <gitster@pobox.com> wrote: >> Would it be equally a valid fix to use "=" instead of "==", or would >> that change the meaning? This is a bash-only piece of code, so use >> of [[ ... ]] is not technically incorrect, but if the basic [] works >> well enough with "=", we should prefer that. > > Yes, `[` is preferable for portability and they'd behave the same in > this case. I consciously chose to use `[[` because that's what all the > other comparisons in that script use. (I think I noted that in the > commit message, maybe). I think there's value in consistency, and not > enough value of `[` over `[[` to justify changing all the other lines.
I do not know if we mind eventual consistency using [] not [[]], but this topic is certainly not about aiming for consistency.
If the difference affects correctness, as brian mentioned, that is a different matter. We should use [ x = y ] in this patch while leaving the existing uses of [[ x == y ]].
Later in a separate patch series, we may need to examine other uses of [[ x == y ]] and correct the ones that do not need/want the pattern matching semantics to use [ x = y ].