aboutsummaryrefslogtreecommitdiff
path: root/bash-completion
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-08-08 19:38:56 (GMT)
committerSebastien Luttringer <seblu@seblu.net>2011-08-27 17:17:21 (GMT)
commit227b71e67d19f73128862d20aac714537c8517df (patch)
tree75a675b196077ee9cee427b4d9650468e912bcc3 /bash-completion
parent4e573b6b35d4468b4b3856a7784728f75ab2e73a (diff)
downloadinitscripts-227b71e67d19f73128862d20aac714537c8517df.tar.xz
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 <seblu@seblu.net>
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion20
1 files changed, 10 insertions, 10 deletions
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