[Bash-completion-devel] Bug#624703: bash-completion makes bash report an error and doesn't complete

Frank Harwald franki777 at xmail.net
Sat Apr 30 18:50:26 UTC 2011


Package: bash-completion
Version: 1.2-3

There is a bug in bash-completion that makes it print out an error message when trying
to complete any command by hitting <TAB> when bash_completion is loaded and the current
command doesn't get any completion at all. It only works under special circumstances,
e.g. the command line must have a special kind of format and the cursor must be at a
specific position.

It prints out the following error message:
	any_command bash: $index: substring expression < 0
when trying to complete on any command that looks like this egrep-like regex(the bug
only occurs with whitespace and control characters used exactly as specified):
	 any_command (other_option)*[ ]+ last_option\n
	                  cursor is here^           ^
	line end is here(no space after last_option)|

here is an example that triggers the error. Type in the following into bash
> ls  -l
then put the cursor before the minus sign
> ls  -l
     ^cursor is here
than press <TAB> to complete. This is what you should get:
> ls bash: $index: substring expression < 0

I guess the bug is somewhere in __get_cword_at_cursor_by_ref or _get_cword, but I
wasn't able to fix it

It occurs on multiple versions of bash-completion 20080705, 1.2-3 and others probably
too. It also occurs on different versions of bash as well, tested on 3.2.39(1)-release,
4.1-3 and 4.1.7(1)-release on Debian Lenny, Squeeze and even on other Linux distributions.

Since this e-mail is sensitive to whitespaces and e-mail often mangles them, I've put
up a copy here: http://paste.debian.net/115602/







More information about the Bash-completion-devel mailing list