Re: possible bug in autocompletion
- From
Jeff King <peff@peff.net>
- Date
- Sep 19, 2012, 23:43 UTC
- Message-ID
- <20120919234332.GB27626@sigill.intra.peff.net>
- In-Reply-To
- <CAMP44s33b7uNg6G3m3wHEACa_wYwf_5==h64CHw2b86-rJd5VQ@mail.gmail.com>
On Thu, Sep 20, 2012 at 01:08:29AM +0200, Felipe Contreras wrote:
Show 14 quoted lines
> On Wed, Sep 19, 2012 at 9:55 PM, Jeff King <peff@peff.net> wrote:
>
> > I have no idea if that internal to bash's filename completion, or if
> > there is some easy facility offered to programmable completions to do
> > the same thing. I don't think this is a high priority, but it would be
> > nice to handle it. And moreover, I am really wondering if we are missing
> > some solution that bash is providing to help us with the quoting issues.
> > Surely we are not the first completion script to come up against this.
>
> I found a much easier solution:
>
> - COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
> + COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$(quote "$1")"
> -- "${3-$cur}"))Oh, nice. :)
Show 9 quoted lines
> But what about the people that don't have bash-completion?
>
> BTW:
>
> quote()
> {
> local quoted=${1//\'/\'\\\'\'}
> printf "'%s'" "$quoted"
> }That is short and obvious enough that we could probably just cut-and-paste it into our script as _git_quote (and it is basically a cleaner version of the thing that I posted).
-Peff