a48f80c
From 8d660f18b2b967f43b5891958553f0319d4f9f02 Mon Sep 17 00:00:00 2001
a48f80c
From: Eric Cook <llua@gmx.com>
a48f80c
Date: Mon, 18 May 2015 01:02:41 -0400
a48f80c
Subject: [PATCH] zsh-completion: less forking in _systemctl_failed_units() and
a48f80c
 make the array `_sys_failed_units' local to the completer.
a48f80c
a48f80c
(cherry picked from commit 463985a9f489c54b89ee7ce6ffd67501035420b4)
a48f80c
---
a48f80c
 shell-completion/zsh/_systemctl.in | 4 ++--
a48f80c
 1 file changed, 2 insertions(+), 2 deletions(-)
a48f80c
a48f80c
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
a48f80c
index b8921791dd..e95b7d3af0 100644
a48f80c
--- a/shell-completion/zsh/_systemctl.in
a48f80c
+++ b/shell-completion/zsh/_systemctl.in
a48f80c
@@ -165,7 +165,7 @@ _systemctl_restartable_units(){
a48f80c
                                { while read -r a b; do echo -E - " $a"; done; } )) )
a48f80c
 }
a48f80c
 
a48f80c
-_systemctl_failed_units()  {_sys_failed_units=(  $(__systemctl list-units --failed | { while read -r a b; do echo -E - " $a"; done; }) )}
a48f80c
+_systemctl_failed_units()  {_sys_failed_units=( ${${(f)"$(__systemctl list-units --failed)"}%% *} ) }
a48f80c
 _systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files) ) }
a48f80c
 
a48f80c
 local fun
a48f80c
@@ -201,7 +201,7 @@ done
a48f80c
 # Completion functions for FAILED_UNITS
a48f80c
 (( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed()
a48f80c
 {
a48f80c
-  _systemctl_failed_units
a48f80c
+  local _sys_failed_units; _systemctl_failed_units
a48f80c
   compadd "$@" -a - _sys_failed_units || _message "no failed unit found"
a48f80c
 }
a48f80c