git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Robert Estelle via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Robert Estelle <robert.estelle@gmail.com>,
	Robert Estelle <robertestelle@gmail.com>
Subject: Re: [PATCH] completion: fix incorrect bash/zsh string equality check
Date: Fri, 8 Oct 2021 20:57:32 +0000	[thread overview]
Message-ID: <YWCwvOdW/L5aMpr7@camp.crustytoothpaste.net> (raw)
In-Reply-To: <xmqqbl3zjl5y.fsf@gitster.g>

[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]

On 2021-10-08 at 20:50:33, Junio C Hamano wrote:
> "Robert Estelle via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> >     This fixes an error in contrib/completion/git-completion.bash caused by
> >     the incorrect use of == (vs. single =) inside a basic [/test command.
> >     Double-equals == should only be used with the extended [[ comparison.
> 
> Curious.
> 
> 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.

It's actually preferable in most cases to use [ and = rather than [[ and
==, because the former looks for strict equality and the latter looks
for pattern matching.  If one is placing a glob pattern on the right
side, then [[ and == can be desirable, but otherwise it's better to
stick to the POSIX syntax.
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2021-10-08 20:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 21:39 [PATCH] completion: fix incorrect bash/zsh string equality check Robert Estelle via GitGitGadget
2021-10-08 20:50 ` Junio C Hamano
2021-10-08 20:57   ` brian m. carlson [this message]
2021-10-08 22:17     ` Robert Estelle
2021-10-08 22:05   ` Robert Estelle
2021-10-08 22:16     ` Junio C Hamano
2021-10-08 22:26       ` Robert Estelle
2021-10-08 23:09         ` Junio C Hamano
2021-10-25 22:20           ` Robert Estelle
2021-10-25 22:29 ` [PATCH v2] " Robert Estelle via GitGitGadget
2021-10-28 16:36   ` 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=YWCwvOdW/L5aMpr7@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=robert.estelle@gmail.com \
    --cc=robertestelle@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).