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 11, 2011, 21:09 UTC
Message-ID
<20110511210941.GC31029@goldbirke>
In-Reply-To
<20110510234552.GG1994@elie>
Hi,
On Tue, May 10, 2011 at 06:45:52PM -0500, Jonathan Nieder wrote:
Show 9 quoted lines
> SZEDER Gábor wrote:
> > 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.
> 
> FWIW it looks like the bash-completion lib adopted a different fix
> recently: see [1] (_init_completion: Indicate that completion should
> not continue if cword == 0, 2011-05-02).
> 
> [1] http://git.debian.org/?p=bash-completion/bash-completion.git;a=commitdiff;h=457dbf6061eea5f2d1e3bccacf1691265f7321cc

That doesn't fix the issue at hand. _init_completion() invokes _get_comp_words_by_ref() before that check to set all variables [1], which will in turn try to access the -1th element of the array when setting $prev, producing the same error.

Best, Gábor

[1]: http://git.debian.org/?p=bash-completion/bash-completion.git;a=blob;f=bash_completion;h=e88e2fc8cd97f2a43173b45a1448451bb53e55ab;hb=457dbf6061eea5f2d1e3bccacf1691265f7321cc#l708
Previous: Jonathan NiederNext: SZEDER Gábor
Message 10 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.