bash-completion: use improved filtering to make things faster

(cherry picked from commit 372b221166)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2014-11-02 16:40:27 -05:00
parent ff0c10038b
commit fef18888ca
+11 -5
View File
@@ -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; }; }