From 227b71e67d19f73128862d20aac714537c8517df Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer Date: Mon, 8 Aug 2011 21:38:56 +0200 Subject: rc.d: handle a set of options rc.d can now take --started, --stopped, --auto, --noauto as option which help user to filter list of daemon for all actions As a corollary list command can now take a list of dameon to display All kind of arguments can be mixed to obtain the proper output. zsh and bash completion are updated Note: Output of help command exit 0 and is no more printed on stderr Signed-off-by: Sebastien Luttringer --- bash-completion | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'bash-completion') diff --git a/bash-completion b/bash-completion index d78484e..4b4593b 100644 --- a/bash-completion +++ b/bash-completion @@ -3,20 +3,20 @@ _rc_d() { local action cur prev - action="help list start stop reload restart" + actions='help list start stop reload restart' + options='-s --started -S --stopped -a --auto -A --noauto' _get_comp_words_by_ref cur prev - if ((COMP_CWORD == 1)); then - COMPREPLY=($(compgen -W "${action}" -- "$cur")) - elif [[ "$prev" == help ]]; then + _get_first_arg + if [[ -z "$arg" ]]; then + COMPREPLY=($(compgen -W "${actions} ${options}" -- "$cur")) + elif [[ "$arg" == help ]]; then COMPREPLY=() - elif [[ "$prev" == list ]]; then - ((COMP_CWORD == 2)) && COMPREPLY=($(compgen -W "started stopped" -- "$cur")) || COMPREPLY=() - elif [[ "$prev" == start ]]; then + elif [[ "$arg" == start ]]; then COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort))) - elif [[ "$prev" =~ stop|restart|reload ]]; then + elif [[ "$arg" =~ stop|restart|reload ]]; then COMPREPLY=($(cd /run/daemons/ && compgen -f "$cur"|sort)) - elif ((COMP_CWORD > 1)); then - COMPREPLY=($(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort)) + else + COMPREPLY=($(compgen -W "${options} $(cd /etc/rc.d && compgen -f -X 'functions*')" -- "$cur")) fi } complete -F _rc_d rc.d -- cgit v1.2.3