From 36cc40a9d641058ae69ca64a4661d5900098ab12 Mon Sep 17 00:00:00 2001 From: NRK Date: Wed, 1 Feb 2023 20:03:16 +0600 Subject: bash-completions/rc-service: don't use grep Co-authored-by: Mike Frysinger Closes: https://github.com/OpenRC/openrc/issues/344 --- bash-completion/rc-service | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'bash-completion/rc-service') diff --git a/bash-completion/rc-service b/bash-completion/rc-service index a197655f..4e9e076e 100644 --- a/bash-completion/rc-service +++ b/bash-completion/rc-service @@ -85,9 +85,9 @@ _rc_service() else # no option was typed if [[ ${COMP_CWORD} -eq 1 ]]; then # if first word typed - words="$(rc-service --list | grep ^${cur})" # complete for init scripts - COMPREPLY=($(for i in ${words} ; do \ - [[ ${i} == ${cur}* ]] && echo ${i} ; \ + # complete for init scripts + COMPREPLY=($(for i in $(rc-service --list) ; do \ + [[ ${i} == "${cur}"* ]] && echo ${i} ; \ done)) return 0 elif [[ ${COMP_CWORD} -eq 2 ]] && [[ ${prev} != -* ]]; then # if second word typed and we didn't type in a function @@ -105,9 +105,8 @@ _rc_service() fi if [[ ${action} == '--exists' ]] || [[ ${action} == '-e' ]] || \ [[ ${action} == '--resolve' ]] || [[ ${action} == '-r' ]]; then - words="$(rc-service --list | grep ^${cur})" - COMPREPLY=($(for i in ${words} ; do \ - [[ ${i} == ${cur}* ]] && echo ${i} ; \ + COMPREPLY=($(for i in $(rc-service --list) ; do \ + [[ ${i} == "${cur}"* ]] && echo ${i} ; \ done)) return 0 fi -- cgit v1.2.3