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

Re: [BUG] Autocompletion fails with "bash: words: bad array subscript"

From
SZEDER Gábor <szeder@ira.uka.de>
Date
May 10, 2011, 22:39 UTC
Message-ID
<20110510223935.GA31029@goldbirke>
In-Reply-To
<20110510211016.GB26231@sigill.intra.peff.net>
Hi,
On Tue, May 10, 2011 at 05:10:16PM -0400, Jeff King wrote:
Show 13 quoted lines
> On Tue, May 10, 2011 at 11:02:53PM +0200, Sverre Rabbelier wrote:
> 
> > On Tue, May 10, 2011 at 23:01, Jeff King <peff@peff.net> wrote:
> > > Right. Bash calls into our __git() completion function, which calls the
> > > implementation of _get_comp_words_by_ref from /etc/bash_completion,
> > > which has the bug. If you don't source git completion, then you are just
> > > getting bash's default file completion.
> > 
> > So should we file this bug with bash's completion people?
> 
> Probably, but it would be nice to reduce it to a smaller test case (or
> one that happens just with completions shipped by Debian) just to rule
> out anything git is doing.

Thinking a bit more about it, you don't even need to search history to reproduce. Try this:

  _foo ()
  {
          local prev
          _get_comp_words_by_ref prev
  }
  complete -F _foo foo

Then type "foo", go back to the very beginning of the command line, and then press TAB, and the same "bash: words: bad array subscript" error appears.

So the bug is definitely not git-related. The fix would be a check along the lines of the first two hunks of the patch I just sent out. Oddly enough, the bash-completion folks had a similar check in the now deprecated _get_pword() function, that didn't made it into _get_comp_words_by_ref()...

Best, Gábor

Previous: Jeff KingNext: Jonathan Nieder
Message 8 of 12 in “[BUG] Autocompletion fails with "bash: words: bad array subscript"”
  1. Sverre RabbelierMay 10, 2011
  2. Jeff KingMay 10, 2011
  3. Jeff KingMay 10, 2011
  4. Sverre RabbelierMay 10, 2011
  5. Jeff KingMay 10, 2011
  6. Sverre RabbelierMay 10, 2011
  7. Jeff KingMay 10, 2011
  8. SZEDER GáborMay 10, 2011
  9. Jonathan NiederMay 10, 2011
  10. SZEDER GáborMay 11, 2011
  11. completion: fix array indexing error after reverse history searchSZEDER Gábor, May 10, 2011
  12. Sverre RabbelierMay 10, 2011

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.