command / directory mixup for completion of args to meta-commands like sudo

Bug #1095180 reported by Rolf Leggewie
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash-completion (Ubuntu)
Confirmed
Low
Unassigned
Nominated for Precise by Thomas Ward
Nominated for Quantal by Thomas Ward

Bug Description

bash-completion in precise is faulty

$ cd /etc
$ sudo etckeTAB

that completes to

$ sudo etckeeper/

when it should complete only to

$ sudo etckeeper

------
Notes from comments:

Original report:
Release: Ubuntu Precise 12.04
Package Version: etckeeper 0.61ubuntu2

Additionally confirmed on (by teward):
Release: Ubuntu Quantal 12.10
Package Version: etckeeper 0.61ubuntu2

Additionally confirmed on (by teward):
Release: Ubuntu Raring 13.04 - Daily Image from 2013-01-04
Package Version: etckeeper 0.61ubuntu2

Revision history for this message
Rolf Leggewie (r0lf) wrote :

another example

$ man etckeTAB
etckeeper/ etckeeper/

Rolf Leggewie (r0lf)
description: updated
description: updated
Revision history for this message
Thomas Ward (teward) wrote :

Hello, and thanks for reporting your bug!

We need a little bit more information from you about the system and what version of the software you are using.

Can you please include the output of `lsb_release -a` (which will tell us which version of Ubuntu you are using) and `dpkg -l etckeeper\*` (which will tell us which version of etckeeper you are using) to your bug as a comment?

------
Thomas Ward
BugSquad Member

Changed in etckeeper (Ubuntu):
status: New → Incomplete
Revision history for this message
Rolf Leggewie (r0lf) wrote :

Thank you for having a look at the ticket, Thomas. As stated in the original bug report, my system runs precise. I have the latest package of etckeeper from precise installed which happens to be 0.61ubuntu2.

Revision history for this message
Thomas Ward (teward) wrote :

Thanks for providing the additional information!

I've added the information you provided in Comment #3 to the bug description, tagged the bug as "Precise", and returned the bug status back to "New" so someone can try and confirm this.

I would suggest that in future you use this command when filing a bug: ubuntu-bug [package]

This will add important information such as the release you're using, the version of the package, and other information that could be useful for triagers and developers.

------
Thomas Ward
Ubuntu BugSquad Member

tags: added: precise
description: updated
Changed in etckeeper (Ubuntu):
status: Incomplete → New
Revision history for this message
Thomas Ward (teward) wrote :

Okay, so I spun up a VM for Lubuntu 12.04, and dropped it into tty mode.

After installing etckeeper (sudo apt-get install etckeeper) after updating the packages, I can confirm this issue happens on Precise.

I can also reproduce this with Quantal.

But there's specific information here that I think needs to be added: the bash completion of just etcke[TAB] *correctly* tabcompletes as 'etckeeper'. This is in both user-space terminal logins as well as root logins, confirmed in both 12.04 and 12.10.

I don't have a spare Raring VM to test with, so I'm going to spin one up and see if I can confirm it there.

Adding 'quantal' tag, and marking confirmed in the meantime.

Changed in etckeeper (Ubuntu):
status: New → Confirmed
tags: added: quantal
description: updated
Revision history for this message
Thomas Ward (teward) wrote :

Also confirmed in Raring. Although, the same "Additional details" I added in Comment #5 are still valid. Perhaps this is an issue with how 'sudo' affects bash completion?

Adding 'raring' tags, and nominating against Precise and Quantal.

tags: added: raring
description: updated
Thomas Ward (teward)
Changed in etckeeper (Ubuntu):
importance: Undecided → Low
Changed in bash-completion (Ubuntu):
importance: Undecided → Low
Revision history for this message
Rolf Leggewie (r0lf) wrote :

Thanks, Thomas. Still the same in trusty.

summary: - incorrect bash-completion
+ incorrect bash-completion for sudo
Rolf Leggewie (r0lf)
Changed in bash-completion (Ubuntu):
status: New → Confirmed
tags: added: trusty
Revision history for this message
Peter Cordes (peter-cordes) wrote : Re: incorrect bash-completion for sudo

It's a corner case of a directory in the current directory having the same name as a command. The directory entry is superseding the command completion.

 If you sudo et<tab> you get a list of completions. In /etc, the only entry for etckeeper is with a trailing /, rather than having an entry for the command AND an entry for the directory. If you are cded to somewhere without an etckeeper directory present, etckeeper is fine.

 This happens with completion for any commands flagged to take another command as their first argument. simple testcase:
mkdir apt-g{,et}
nice apt-g<tab> => lists apt-g/ apt-get/
nice apt-ge<tab> => nice apt-get/

Probably fixable without disabling completing filenames as a fallback, IDK. _command_offset() is pretty complex, I'm prob. not going to try to fix it myself.

Revision history for this message
Peter Cordes (peter-cordes) wrote :
Changed in etckeeper (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
Peter Cordes (peter-cordes) wrote :

The bug is in the core code of bash_completion, in the functions that handle commands that take other commands as their arguments, e.g. sudo, nice, and so on. Marked invalid for the etckeeper package, but still confirmed for bash-completion. (I hope I'm doing this right. If there's a way to un-assign it from etckeeper altogether, that would be best).

affects: etckeeper (Ubuntu) → ubuntu
affects: ubuntu → etckeeper (Ubuntu)
summary: - incorrect bash-completion for sudo
+ command / directory mixup for completion of args to meta-commands like
+ sudo
Mathew Hodson (mhodson)
no longer affects: etckeeper (Ubuntu)
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.