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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2021-10-08 at 20:50:33, Junio C Hamano wrote:
> "Robert Estelle via GitGitGadget" <gitgitgadget@xxxxxxxxx> 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: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux