summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mack <github@zonque.org>2015-06-11 12:51:27 +0200
committerDaniel Mack <github@zonque.org>2015-06-11 12:51:27 +0200
commit4aa2764cade3e6d5233f2e390d64931d5cff1410 (patch)
tree4abdbed8f3df3b70def16e74b8f83fb9018b5678
parentd814f9904bb9705070dde8458464b8afe6cfbb22 (diff)
parenta0ab162a097c7d8ea4dbd4d868de5236610e8f14 (diff)
Merge pull request #84 from blueyed/zsh-optimize-filter_units_by_property
zsh-completion: optimize _filter_units_by_property
-rw-r--r--shell-completion/zsh/_systemctl.in15
1 files changed, 5 insertions, 10 deletions
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
index 17736de01c..4bf306aacb 100644
--- a/shell-completion/zsh/_systemctl.in
+++ b/shell-completion/zsh/_systemctl.in
@@ -127,16 +127,11 @@ _systemctl_really_all_units()
_filter_units_by_property() {
local property=$1 value=$2 ; shift ; shift
local -a units ; units=($*)
- local prop unit
- for ((i=1; $i <= ${#units[*]}; i++)); do
- # FIXME: "Failed to issue method call: Unknown unit" errors are ignored for
- # now (related to DBUS_ERROR_UNKNOWN_OBJECT). in the future, we need to
- # revert to calling 'systemctl show' once for all units, which is way
- # faster
- unit=${units[i]}
- prop=${(f)"$(_call_program units "$service show --no-pager --property="$property" ${unit} 2>/dev/null")"}
- if [[ "${prop}" = "$property=$value" ]]; then
- echo -E - " ${unit}"
+ local props
+ for props in ${(ps:\n\n:)"$(_call_program units "$service show --no-pager --property="Id,$property" -- ${units} 2>/dev/null")"}; do
+ props=(${(f)props})
+ if [[ "${props[2]}" = "$property=$value" ]]; then
+ echo -E - " ${props[1]#Id=}"
fi
done
}