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

[PATCH] zsh completion: 5.0.3 compat, use emulate

From
PPPhil Pennock <pdp@spodhuis.org>
Date
Dec 16, 2013, 08:32 UTC
Message-ID
<EMXW5CZ-001FUQ-3S@ilmenite.field.spodhuis.org>

The bash completion pulled into zsh was being pulled in _as_ zsh, but used patterns which relied on falling through as unhandled. In zsh 5.0.3 this no longer works, resulting in:

    __git_complete_remote_or_refspec:33: bad pattern: +*

Fix by telling zsh to emulate sh while sourcing the bash config file, which stickily preserves compatibility options in the function context. This usage of "emulate" came in with zsh 4.3.10, released 2009-06-01.

Signed-off-by: Phil Pennock <pdp@spodhuis.org>
---
nb: I am not on the git mailing-list, please keep me CC'd.
    I have read SubmittingPatches but let me know if I've missed something.
    Fix applies (unmodified) to both master and maint.
    Thanks.
 contrib/completion/git-completion.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.zsh b/contrib/completion/git-completion.zsh
index fac5e71..d898b65 100644
--- a/contrib/completion/git-completion.zsh
+++ b/contrib/completion/git-completion.zsh
@@ -39,7 +39,7 @@ if [ -z "$script" ]; then
 		test -f $e && script="$e" && break
 	done
 fi
-ZSH_VERSION='' . "$script"
+emulate sh -c 'ZSH_VERSION="" . "$script"'
 
 __gitcomp ()
 {
-- 
1.8.5.1
Next: Felipe Contreras
Message 1 of 4 in “zsh completion: 5.0.3 compat, use emulate”
  1. zsh completion: 5.0.3 compat, use emulatePhil Pennock, Dec 16, 2013
  2. Felipe ContrerasApr 30, 2014
  3. Felipe ContrerasApr 30, 2014
  4. Phil PennockApr 30, 2014

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.