Upstart
Tom H
tomh0665 at gmail.com
Tue Mar 9 13:59:19 UTC 2010
>>> 999. Could initctl be made to recognize, for example, both
>>> avahi-daemon and avahi-daemon.conf? (If I am in /etc/init - it is rare
>>> but it happens - and type "stop av//tab//", I end up with "stop
>>> avahi-daemon.conf" which, after pressing //enter// results in an
>>> "unknown job" message.)
>> That sounds like the lack of a specialised bash-completion function?
> This seems to do the job (except for completions of arguments for --dest):
> --8<---------------cut here---------------start------------->8---
> _stop()
> {
> local cur
>
> COMPREPLY=()
> cur=${COMP_WORDS[COMP_CWORD]}
>
> case "$cur" in
> -*)
> COMPREPLY=( $( compgen -W '-n --no-wait --system --dest -q --quiet -v --verbose --help --version' -- $cur ) )
> ;;
> *)
> COMPREPLY=( $(initctl list| awk "/^$cur/ {print \$1}" ) )
> ;;
> esac
>
> return 0
>
> }
> complete -F _stop stop
> --8<---------------cut here---------------end--------------->8---
It works perfectly, thanks. I have never used bash_completion before;
it completes "avahi-daemon" no matter which dir I am in.
More information about the Ubuntu-devel-discuss
mailing list