]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Slightly improve performance of startable/restartable unit completion (#7839)
authordana <dana@dana.is>
Sun, 28 Jan 2018 12:29:58 +0000 (06:29 -0600)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 28 Jan 2018 12:29:58 +0000 (13:29 +0100)
shell-completion/zsh/_systemctl.in

index 47ec9970e141b9ef22c6721c19a92808deaceabd..a3df9a04576a2ac1973fa8e319ff699b04f9d798 100644 (file)
@@ -140,20 +140,19 @@ _systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-uni
 _systemctl_active_units()  {_sys_active_units=(  ${${(f)"$(__systemctl list-units "*$PREFIX*$SUFFIX*" )"}%% *} )}
 
 _systemctl_startable_units(){
-    _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $(
-                          _filter_units_by_property CanStart yes $(
-                          __systemctl $mode list-unit-files --state enabled,disabled,static "*$PREFIX*$SUFFIX*" | \
-                               { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
-                          __systemctl $mode list-units --state inactive,failed "*$PREFIX*$SUFFIX*" | \
-                               { while read -r a b; do echo -E - " $a"; done; } )) ) )
+  _sys_startable_units=( $( _filter_units_by_property ActiveState inactive $(
+    _filter_units_by_property CanStart yes ${${${(f)"$(
+      __systemctl $mode list-unit-files --state enabled,disabled,static "*$PREFIX*$SUFFIX*"
+      __systemctl $mode list-units --state inactive,failed "*$PREFIX*$SUFFIX*"
+    )"}:#*@.*}%%[[:space:]]*}
+  )) )
 }
 
 _systemctl_restartable_units(){
-    _sys_restartable_units=( $(_filter_units_by_property CanStart yes $(
-                          __systemctl $mode list-unit-files --state enabled,disabled,static "*$PREFIX*$SUFFIX*" | \
-                               { while read -r a b; do [[ $a =~ @\. ]] || echo -E - " $a"; done; }
-                          __systemctl $mode list-units "*$PREFIX*$SUFFIX*" | \
-                               { while read -r a b; do echo -E - " $a"; done; } )) )
+  _sys_restartable_units=( $( _filter_units_by_property CanStart yes ${${${(f)"$(
+    __systemctl $mode list-unit-files --state enabled,disabled,static "*$PREFIX*$SUFFIX*"
+    __systemctl $mode list-units "*$PREFIX*$SUFFIX*"
+  )"}:#*@.*}%%[[:space:]]*} ) )
 }
 
 _systemctl_failed_units()  {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "*$PREFIX*$SUFFIX*" )"}%% *} ) }