[Bash-completion-devel] [PATCH] Bug#559953: COMP_WORDS: bad array subscript

Ville Skyttä ville.skytta at iki.fi
Sun May 1 14:40:53 UTC 2011


On 04/29/2011 12:39 PM, Igor Murzov wrote:
>> This message also appears when you press tab with the cursor at the
>> beginning of certain commands.
>> To reproduce this write "dpkg" move cursor above "d" and hit tab, this one
>> is specially annoying since message is repeated until you press ctrl-c
>> This happens a lot to me when I use reverse-i-search (ctrl-r) and I press
>> tab by mistake
>> similar behavior with ls, cp, grep, ssh, man, uname, chown...
> 
> In this case $cword equals to zero and _init_completion tries to put 
> ${words[cword-1]} into prev, At this point out of bounds access occurs.

I applied the _init_completion change with a minor modification, but did
not touch _get_comp_words_by_ref yet as I suppose we might have some
other related problems in it which were not addressed by your patch (it
silenced the warning, but didn't produce the results that I would have
found correct).

For example, write "ls" and then go to the start of line, what do you
think $cur and $prev should be set to when completing at that point?  I
think both of them should be empty, but then again I also think that in
that case the "ls" completion should not be invoked at all which may be
a bash bug.  I added some test cases that fail at the moment for this,
and will report to the Alioth tracker hoping Freddy will find time to
look into this.

http://git.debian.org/?p=bash-completion/bash-completion.git;a=commitdiff;h=41ce815827029c1492eb208aa6e6b2aa49caa551



More information about the Bash-completion-devel mailing list