Skip to content

Commit db8d750

Browse files
jszakmeistergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 282616c commit db8d750

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ _git_gitk ()
12981298
}
12991299

13001300
__git_match_ctag() {
1301-
awk "/^${1////\\/}/ { print \$1 }" "$2"
1301+
awk "/^${1//\//\\/}/ { print \$1 }" "$2"
13021302
}
13031303

13041304
_git_grep ()

0 commit comments

Comments
 (0)