git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Felipe ContrerasNext: Junio C Hamano
Message 9 of 10 in “possible bug in autocompletion”
  1. Jeroen MeijerJul 17, 2012
  2. Jeff KingJul 17, 2012
  3. Felipe ContrerasSep 19, 2012
  4. Jeff KingSep 19, 2012
  5. Felipe ContrerasSep 19, 2012
  6. Felipe ContrerasSep 19, 2012
  7. Jeff KingSep 19, 2012
  8. Felipe ContrerasSep 19, 2012
  9. Jeff KingSep 19, 2012
  10. Junio C HamanoSep 19, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.