From db8d750876ce9c43b23ddfdbe618ec5dd12767ee Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Sat, 14 Mar 2015 09:40:39 -0400 Subject: [PATCH] contrib/completion: escape the forward slash in __git_match_ctag The current definition results in an incorrect expansion of the term under zsh. For instance "/^${1////\\/}/" under zsh with the argument "hi" results in: /^/\/h/\/i/ This results in an output similar to this when trying to complete `git grep chartab` under zsh: :: git grep chartabawk: cmd. line:1: /^/\/c/\/h/\/a/\/r/\/t/\/a/\/b/ { print $1 } awk: cmd. line:1: ^ backslash not last character on line awk: cmd. line:1: /^/\/c/\/h/\/a/\/r/\/t/\/a/\/b/ { print $1 } awk: cmd. line:1: ^ syntax error Leaving the prompt in a goofy state until the user hits a key. Escaping the literal / in the parameter expansion (using "/^${1//\//\\/}/") results in: /^chartab/ allowing the completion to work correctly. This formulation also works under bash. Signed-off-by: John Szakmeister Signed-off-by: Junio C Hamano --- 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 019026efcb..72a31827e1 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1298,7 +1298,7 @@ _git_gitk () } __git_match_ctag() { - awk "/^${1////\\/}/ { print \$1 }" "$2" + awk "/^${1//\//\\/}/ { print \$1 }" "$2" } _git_grep () -- 2.11.4.GIT