From: Zbigniew Jędrzejewski-Szmek Date: Thu, 30 Oct 2014 03:06:58 +0000 (-0400) Subject: bash-completion: use improved filtering to make things faster X-Git-Tag: v218~665 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=372b221166eb586c4f767969f442ed940e21f353 bash-completion: use improved filtering to make things faster --- diff --git a/shell-completion/bash/systemctl.in b/shell-completion/bash/systemctl.in index 9e538a9a5..9e98a1850 100644 --- a/shell-completion/bash/systemctl.in +++ b/shell-completion/bash/systemctl.in @@ -60,14 +60,20 @@ __get_active_units () { __systemctl $1 list-units \ | { while read -r a b; do echo " $a"; done; }; } __get_startable_units () { # find startable inactive units - __filter_units_by_property $mode LoadState loaded $( - __filter_units_by_property $mode ActiveState inactive $( - __filter_units_by_property $mode CanStart yes $( __get_all_units ))) + __filter_units_by_property $mode ActiveState inactive $( + __filter_units_by_property $mode CanStart yes $( + __systemctl $mode list-unit-files --state enabled,disabled,static | \ + { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } + __systemctl $mode list-units --state inactive,failed | \ + { while read -r a b; do echo " $a"; done; } )) } __get_restartable_units () { # filter out masked and not-found - __filter_units_by_property $mode LoadState loaded $( - __filter_units_by_property $mode CanStart yes $( __get_all_units )) + __filter_units_by_property $mode CanStart yes $( + __systemctl $mode list-unit-files --state enabled,disabled,static | \ + { while read -r a b; do [[ $a =~ @\. ]] || echo " $a"; done; } + __systemctl $mode list-units | \ + { while read -r a b; do echo " $a"; done; } ) } __get_failed_units () { __systemctl $1 list-units \ | { while read -r a b c d; do [[ $c == "failed" ]] && echo " $a"; done; }; }