summaryrefslogtreecommitdiff
path: root/bash-completion
diff options
context:
space:
mode:
authorSebastien Luttringer <seblu@seblu.net>2011-06-27 00:23:20 +0200
committerSebastien Luttringer <seblu@seblu.net>2011-06-27 00:23:20 +0200
commit0ab093ba1cfc2d0aeadfc5a0c2af59f80781b5fa (patch)
tree41f66da39476ef5ce9d534b6b3ba11f786ec234b /bash-completion
parent713213c19395fd1541cdaa025ac5f977d062108a (diff)
Use _get_comp_words_by_ref in bash completion
Thanks Dave Reisner for suggestion Signed-off-by: Sebastien Luttringer <seblu@seblu.net>
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion14
1 files changed, 7 insertions, 7 deletions
diff --git a/bash-completion b/bash-completion
index 489b5dc..e63e880 100644
--- a/bash-completion
+++ b/bash-completion
@@ -2,18 +2,18 @@
_rc.d ()
{
- local action="help list start stop reload restart"
- local cur="${COMP_WORDS[COMP_CWORD]}"
- local caction="${COMP_WORDS[1]}"
+ local action cur prev
+ action="help list start stop reload restart"
+ _get_comp_words_by_ref cur prev
if ((COMP_CWORD == 1)); then
COMPREPLY=($(compgen -W "${action}" -- "$cur"))
- elif [[ "$caction" == help ]]; then
+ elif [[ "$prev" == help ]]; then
COMPREPLY=()
- elif [[ "$caction" == list ]]; then
+ elif [[ "$prev" == list ]]; then
((COMP_CWORD == 2)) && COMPREPLY=($(compgen -W "started stopped" -- "$cur")) || COMPREPLY=()
- elif [[ "$caction" == start ]]; then
+ elif [[ "$prev" == start ]]; then
COMPREPLY=($(comm -23 <(cd /etc/rc.d && compgen -f -X 'functions*' "$cur"|sort) <(cd /run/daemons/ && compgen -f "$cur"|sort)))
- elif [[ "$caction" =~ stop|restart|reload ]]; then
+ elif [[ "$prev" =~ 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))