git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] completion: fix incorrect bash/zsh string equality check
@ 2021-10-07 21:39 Robert Estelle via GitGitGadget
  2021-10-08 20:50 ` Junio C Hamano
  2021-10-25 22:29 ` [PATCH v2] " Robert Estelle via GitGitGadget
  0 siblings, 2 replies; 11+ messages in thread
From: Robert Estelle via GitGitGadget @ 2021-10-07 21:39 UTC (permalink / raw)
  To: git; +Cc: Robert Estelle, Robert Estelle

From: Robert Estelle <robertestelle@gmail.com>

In the basic `[`/`test` command, the string equality operator is a
single `=`. The `==` operator is only available in `[[`, which is a
bash-ism also supported by zsh.

This mix-up was causing the following completion error in zsh:
> __git_ls_files_helper:7: = not found

(That message refers to the extraneous symbol in `==` ← `=`).

This updates that comparison to use the extended `[[ … ]]` conditional
for consistency with the other checks in this file.

Signed-off-by: Robert Estelle <robertestelle@gmail.com>
---
    completion: Fix incorrect bash/zsh string equality check
    
    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.
    
    This was causing the following completion error in zsh:
    
    > __git_ls_files_helper:7: = not found
    
    
    That message refers to the extraneous = symbol in ==.
    
    This updates that comparison to use the extended [[ … ]] conditional for
    consistency with the other checks in this file.
    
    Note that there may be some contributing cause to this error related to
    emulation mode inheritance/stickiness, since it seems that the function
    is intended to run with emulate ksh and that does not appear to be
    happening properly. Nevertheless, fixing this comparison fixes this
    particular error in a compatible way, and I have not observed any other
    errors.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1096%2Frwe%2Ffix-completion-sh-eq-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1096/rwe/fix-completion-sh-eq-v1
Pull-Request: https://github.com/git/git/pull/1096

 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 4bdd27ddc87..14de5efa734 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -515,7 +515,7 @@ __gitcomp_file ()
 # argument, and using the options specified in the second argument.
 __git_ls_files_helper ()
 {
-	if [ "$2" == "--committable" ]; then
+	if [[ "$2" == "--committable" ]]; then
 		__git -C "$1" -c core.quotePath=false diff-index \
 			--name-only --relative HEAD -- "${3//\\/\\\\}*"
 	else

base-commit: 225bc32a989d7a22fa6addafd4ce7dcd04675dbf
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-10-28 16:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).