bash completion doesn't work in the middle of a word

Bug #139666 reported by Adam Simpkins
6
Affects Status Importance Assigned to Milestone
bash-completion (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: bash

In feisty, the /etc/bash_completion file uses ${COMP_WORDS[COMP_CWORD]}" to
find the token being completed. This isn't quite correct, since it always
returns the full token, even if the cursor is in the middle of the token.

For example, say the command line currently is:

    $ ls foobar
            ^
and the cursor is on the 'b' character. Attempting to perform completion here
should complete the token "foo", and insert the results found before "bar".
With the current code, it tries to complete the full token "foobar", and then
inserts the results before "bar".

I occasionally run into this problem, for example, when I try to perform
completion on a file, but then realize I'm in the parent directory instead of
the directory I was thinking about. I type the filename and try to complete
it. When this fails, I realize I'm in the parent directory, so I go back to
the beginning of the token, insert the first few characters of the directory
name, and try to complete the directory name.

This works with bash's default builtin completion. However, if I have sourced
/etc/bash_completion it doesn't work, since it tries to complete the entire
token, not just the part up to the cursor.

This can be fixed by examining $COMP_LINE and $COMP_POINT, instead of
${COMP_WORDS[COMP_CWORD]}. I'll attach a patch.

Revision history for this message
Adam Simpkins (simpkins) wrote :
Matthias Klose (doko)
Changed in bash:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Mika Fischer (zoop) wrote :

This was fixed in 20060301-0ubuntu1

Changed in bash-completion:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.