Thread (1 message) 1 message, 1 author, 2016-06-15

Re: possible bug in autocompletion

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:49

Felipe Contreras [off-list ref] writes:
On Tue, Jul 17, 2012 at 2:12 PM, Jeff King [off-list ref] wrote:
quoted
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -261,7 +261,12 @@ __gitcomp ()
 __gitcomp_nl ()
 {
        local IFS=$'\n'
-       COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
+       local words=$1
+       words=${words//\\/\\\\}
+       words=${words//\$/\\\$}
+       words=${words//\'/\\\'}
+       words=${words//\"/\\\"}
+       COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$words" -- "${3-$cur}"))
 }
What about something like this?

local words
printf -v words "%q" "$w"
COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$words" -- "${3-$cur}"))
Both "printf -v" and "%q" are brilliant ;-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help