summaryrefslogtreecommitdiff
path: root/shell-completion
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2018-04-30 13:37:51 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2018-06-11 17:09:56 +0100
commitff728637cc5013e3b58b4fa5c6cf39e662c5474b (patch)
tree8b7ae392b8a28f49e31a4db9889a2f924736a7a2 /shell-completion
parentc839b729c5f7b08f6d91bf9567d0b1f91d17e0f7 (diff)
zsh-completion: systemctl: pass only $PREFIX* to list-unit*
Using a leading * and $SUFFIX produces misleading results. Let's imagine that one mistypes nect instead of netc, they will get a rather misleading completion like: sys-fs-fuse-connections.mount Not to mention that the execution time is up by ~1/3. time systemctl list-unit-files netctl* -> ~12ms time systemctl list-unit-files *netctl* -> ~17ms Furthermore more units are matched, leading to greater execution time of `systemctl show' in _filter_units_by_property Use only $PREFIX*, removing the leading * and trailing $SUFFIX*. Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'shell-completion')
-rw-r--r--shell-completion/zsh/_systemctl.in16
1 files changed, 8 insertions, 8 deletions
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
index 000b58560b..2bb2fff376 100644
--- a/shell-completion/zsh/_systemctl.in
+++ b/shell-completion/zsh/_systemctl.in
@@ -135,29 +135,29 @@ _filter_units_by_property() {
echo -E - "${(@g:o:)${(k@)props[(Re)$property=$value]}#Id=}"
}
-_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "*$PREFIX*$SUFFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ }
+_systemctl_get_template_names() { echo -E - ${^${(M)${(f)"$(__systemctl list-unit-files "$PREFIX*" )"}##*@.[^[:space:]]##}%%@.*}\@ }
-_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units "*$PREFIX*$SUFFIX*" )"}%% *} )}
+_systemctl_active_units() {_sys_active_units=( ${${(f)"$(__systemctl list-units "$PREFIX*" )"}%% *} )}
_systemctl_startable_units(){
_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*"
+ __systemctl $mode list-unit-files --state enabled,disabled,static "$PREFIX*"
+ __systemctl $mode list-units --state inactive,failed "$PREFIX*"
)"}:#*@.*}%%[[:space:]]*}
)) )
}
_systemctl_restartable_units(){
_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*"
+ __systemctl $mode list-unit-files --state enabled,disabled,static "$PREFIX*"
+ __systemctl $mode list-units "$PREFIX*"
)"}:#*@.*}%%[[:space:]]*} ) )
}
-_systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "*$PREFIX*$SUFFIX*" )"}%% *} ) }
-_systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "*$PREFIX*$SUFFIX*" ) ) }
+_systemctl_failed_units() {_sys_failed_units=( ${${(f)"$(__systemctl list-units --state=failed "$PREFIX*" )"}%% *} ) }
+_systemctl_unit_state() { typeset -gA _sys_unit_state; _sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" ) ) }
local fun
# Completion functions for ALL_UNITS