[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 06:46:55 UTC 2011
Bugs item #313065, was changed at 2011-03-31 03:19 by James
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: Nobody (None)
Summary: bash-completion-1.3 doesn't work for "sudo /etc/init.d/xxx <TAB>"
Distribution: Gentoo
Originally reported in: Gentoo Bugzilla
Milestone: None
Status: Invalid
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: James (jamesjjx-guest)
Date: 2011-04-12 14: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 14: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-11 03: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-31 04: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