From 7e95d924c9067d9d643fc3b533f777ea7a5234d7 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Thu, 27 Dec 2018 16:31:15 -0600 Subject: bash-completions/rc-service: allow tab to be used again X-Gentoo-Bug: 670290 X-Gentoo-Bug-URL: https://bugs.gentoo.org/670290 --- bash-completion/rc-service | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'bash-completion') 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 -- cgit v1.2.3