From: Felipe Contreras <felipe.contreras@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Jeroen Meijer <jjgmeijer@hotmail.com>, git@vger.kernel.org
Subject: Re: possible bug in autocompletion
Date: Wed, 19 Sep 2012 20:23:01 +0200 [thread overview]
Message-ID: <CAMP44s1ZVTgBTQDyBHKvos-uSo0FeOO437MvTYH0YE0Lx-xDOA@mail.gmail.com> (raw)
In-Reply-To: <CAMP44s1Xvvs7g1quUEs2b43VciK2=Nt-AntJcwG0CPf6p8Xk_A@mail.gmail.com>
On Wed, Sep 19, 2012 at 8:16 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> On Wed, Sep 19, 2012 at 7:43 PM, Jeff King <peff@peff.net> wrote:
>> On Wed, Sep 19, 2012 at 07:08:09PM +0200, Felipe Contreras wrote:
>>
>>> On Tue, Jul 17, 2012 at 2:12 PM, Jeff King <peff@peff.net> wrote:
>>>
>>> > --- 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}"))
>>
>> Thanks, I didn't know about bash's internal printf magic. That is a much
>> more elegant solution.
>>
>> Care to wrap it up in a patch?
>
> I'm trying to, but unfortunately "\n" gets converted to "\\n", so it
> doesn't get separated to words. Any ideas?
Actually, this seems to do the trick:
local words IFS=$'\n'
printf -v words "%q" "$1"
COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "${words//\\n/$IFS}"
-- "${3-$cur}"))
I don't know how to do $'\n' in the middle of double-quotes, but $IFS works.
--
Felipe Contreras
next prev parent reply other threads:[~2012-09-19 18:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-17 9:10 possible bug in autocompletion Jeroen Meijer
2012-07-17 12:12 ` Jeff King
2012-09-19 17:08 ` Felipe Contreras
2012-09-19 17:43 ` Jeff King
2012-09-19 18:16 ` Felipe Contreras
2012-09-19 18:23 ` Felipe Contreras [this message]
2012-09-19 19:55 ` Jeff King
2012-09-19 23:08 ` Felipe Contreras
2012-09-19 23:43 ` Jeff King
2012-09-19 17:58 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMP44s1ZVTgBTQDyBHKvos-uSo0FeOO437MvTYH0YE0Lx-xDOA@mail.gmail.com \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=jjgmeijer@hotmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).