aboutsummaryrefslogtreecommitdiff
path: root/bash-completion
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2018-12-27 16:31:15 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2018-12-27 16:31:15 -0600
commit7e95d924c9067d9d643fc3b533f777ea7a5234d7 (patch)
treecdab53a13ed029a18ae9ca446a24e3a41b8b15a3 /bash-completion
parenta15b532a02094b3afe9d698f6b98e70f0fd4506a (diff)
bash-completions/rc-service: allow tab to be used again
X-Gentoo-Bug: 670290 X-Gentoo-Bug-URL: https://bugs.gentoo.org/670290
Diffstat (limited to 'bash-completion')
-rw-r--r--bash-completion/rc-service13
1 files changed, 8 insertions, 5 deletions
diff --git a/bash-completion/rc-service b/bash-completion/rc-service
index b4e7709f..b54a2cfb 100644
--- a/bash-completion/rc-service
+++ b/bash-completion/rc-service
@@ -91,11 +91,14 @@ _rc_service()
done))
return 0
elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function
- filename=$(rc-service --resolve ${prev})
- opts=$(cat ${filename} | grep "^\w*()" | sed "s/().*$//") # Greps the functions included in the init script
- if [[ "x${opts}" == "x" ]] ; then # if no options found loosen the grep algorhythm
- opts=$(cat ${filename} | grep "\w*()" | sed "s/().*$//")
- fi
+ rc-service --exists "$prev" || return
+ shopt -s extglob
+ while read -r _ line; do
+ if [[ $line == +([[:alnum:]_]):* ]]; then
+ opts+="${line%%:*} "
+ fi
+ done < <(rc-service "$prev" describe 2>&1)
+ shopt -u extglob
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi