git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] completion: fix incorrect bash/zsh string equality check

From
Robert Estelle <robertestelle@gmail.com>
Date
Oct 8, 2021, 22:26 UTC
Message-ID
<CAMmwyQp7ChC7RZAZX4Y3UyAghOAmvHA7e3BBJonGYJNoSc+nFA@mail.gmail.com>
In-Reply-To
<xmqqh7dri2m1.fsf@gitster.g>

The choice between the two does not affect correctness, it's purely stylistic here. It only would affect correctness for unquoted arguments or extended comparison operators. Those *are* in use elsewhere in this script and force the use of `[[` in those places.

Keep in mind also that this is an autocomplete script. Although it's sourced by both bash and zsh, it does not make sense to attempt to make it work for bare POSIX sh.

On Fri, Oct 8, 2021 at 3:16 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 26 quoted lines
>
> Robert Estelle <robertestelle@gmail.com> writes:
>
> > 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 ].
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 11 in “completion: fix incorrect bash/zsh string equality check”
  1. completion: fix incorrect bash/zsh string equality checkRobert Estelle via GitGitGadget, Oct 7, 2021
  2. Junio C HamanoOct 8, 2021
  3. brian m. carlsonOct 8, 2021
  4. Robert EstelleOct 8, 2021
  5. Robert EstelleOct 8, 2021
  6. Junio C HamanoOct 8, 2021
  7. Robert EstelleOct 8, 2021
  8. Junio C HamanoOct 8, 2021
  9. Robert EstelleOct 25, 2021
  10. completion: fix incorrect bash/zsh string equality checkRobert Estelle via GitGitGadget, Oct 25, 2021
  11. Junio C HamanoOct 28, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.