[Bash-completion-devel] [bash-completion-Bugs][313065] bash-completion-1.3 doesn't work for "sudo /etc/init.d/xxx <TAB>"

bash-completion-bugs at alioth.debian.org bash-completion-bugs at alioth.debian.org
Tue Apr 12 17:31:19 UTC 2011


Bugs item #313065, was changed at 2011-03-30 22:19 by Ville Skyttä 
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=313065&group_id=100114

Status: Closed
Priority: 3
Submitted By: Nobody (None)
>Assigned to: Ville Skyttä  (scop-guest)
Summary: bash-completion-1.3 doesn't work for "sudo /etc/init.d/xxx <TAB>" 
Distribution: Gentoo
Originally reported in: Gentoo Bugzilla
>Milestone: 2.0
>Status: Fix Committed
Original bug number: 360083


Initial Comment:
After typing "sudo /etc/init.d/sshd <TAB>", local files instead of command options(start, stop, etc.) are listed.
The old version 1.2 works fine.

I noticed that the code "complete -p $cmd" has been changed to "complete -p ${cmd##*/}".
Maybe you can check twice: first "complete -p $cmd", and if it fails, run "complete -p ${cmd##*/}"?

James

----------------------------------------------------------------------

>Comment By: Ville Skyttä  (scop-guest)
Date: 2011-04-12 20:31

Message:
It did indeed.  Current git has series of patches to fix this.

----------------------------------------------------------------------

Comment By: Ville Skyttä  (scop-guest)
Date: 2011-04-12 18:50

Message:
Well, as said, it works for me on Fedora 14 both with current git and the 1.3 release.

But then again, I do think it's a bug that we register completion for plain "foo" for /etc/init.d/foo and will look into changing that in git to register only the full path /etc/init.d/foo and /etc/rc.d/init.d/foo (and "service foo"); maybe that'll uncover the issue you see for me too.

----------------------------------------------------------------------

Comment By: James  (jamesjjx-guest)
Date: 2011-04-12 09:46

Message:
well... my point is: it is a bug of _root_command, which is the completion function for sudo.
Actually, the function _gentoo_style_init is never called!
Gentoo registers a completion function _gentoo_style_init for the commands like /etc/init.d/XXX.
After typing "sudo /etc/init.d/XXX <TAB>", _root_command should complete "/etc/init.d/XXX" by calling _gentoo_style_init. Right?
But the version 1.3 code first extracts the command, in this case, "/etc/init.d/XXX", strips away the path and gets the filename, which is XXX, and then seeks for the completion function for XXX.
But XXX is not registered, instead, /etc/init.d/XXX is.

James


----------------------------------------------------------------------

Comment By: Ville Skyttä  (scop-guest)
Date: 2011-04-12 09:24

Message:
_gentoo_style_init is not our function, so I suggest investigating this with Gentoo.  If anybody can reproduce this with the completions shipped by us, feel free to reopen.

----------------------------------------------------------------------

Comment By: James  (jamesjjx-guest)
Date: 2011-04-10 22:52

Message:
james at localhost ~ $ complete | grep sshd
complete -F _gentoo_style_init /etc/init.d/sshd

So I only have completion for /etc/init.d/sshd, no completion for sshd.

Let me make it clearer:
for any service(not only sshd) in the directory of /etc/init.d
1. "/etc/init.d/XXX <TAB>" works correctly by listing options like start, stop, etc.
2. "sudo /etc/init.d/XXX <TAB>" lists local files

James

----------------------------------------------------------------------

Comment By: Ville Skyttä  (scop-guest)
Date: 2011-03-30 23:27

Message:
Works fine for me.  Do you have a separate completion for sshd installed - what does "complete -p sshd" output for you?  

----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=313065&group_id=100114



More information about the Bash-completion-devel mailing list