summaryrefslogtreecommitdiff
path: root/shell-completion/zsh
diff options
context:
space:
mode:
authorАлександр Тихонов <disarmer.mk@gmail.com>2017-01-21 23:53:09 +0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-01-21 14:53:09 -0500
commit88e4dbd505ed4f8480b1f3b837b3c2ac55f1b1dd (patch)
treeb9c64c8d39df3492b0fdba9673db72e0dfea4065 /shell-completion/zsh
parent2feb1c9659f8f9d873615b0c28217a659bdbc86a (diff)
Fixi caching in zsh completion (#5122)
I found several issues with zsh completion code: 1. typo in cache filename: "SYS_ALL_PROPRTIES", so cache just not loading from this file 2. cache stored in one file, despite user or system mode. So it can be loaded later in wrong mode 3. most serious problem: broken logic - it retrieves cache when _cache_invalid is true How to reproduce: type "systemctl --user status <TAB>" and you will see user units. Then press control+C and type "systemctl --system status <TAB>" in same session and you'll see user units again
Diffstat (limited to 'shell-completion/zsh')
-rw-r--r--shell-completion/zsh/_systemctl.in18
1 files changed, 9 insertions, 9 deletions
diff --git a/shell-completion/zsh/_systemctl.in b/shell-completion/zsh/_systemctl.in
index d77a2df74e..553216da5e 100644
--- a/shell-completion/zsh/_systemctl.in
+++ b/shell-completion/zsh/_systemctl.in
@@ -98,11 +98,11 @@ __systemctl()
# Fills the unit list
_systemctl_all_units()
{
- if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) &&
- ! _retrieve_cache SYS_ALL_UNITS;
+ if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS$_sys_service_mgr ) ||
+ ! _retrieve_cache SYS_ALL_UNITS$_sys_service_mgr;
then
_sys_all_units=( ${${(f)"$(__systemctl list-units --all)"}%% *} )
- _store_cache SYS_ALL_UNITS _sys_all_units
+ _store_cache SYS_ALL_UNITS$_sys_service_mgr _sys_all_units
fi
}
@@ -111,14 +111,14 @@ _systemctl_really_all_units()
{
local -a all_unit_files;
local -a really_all_units;
- if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) &&
- ! _retrieve_cache SYS_REALLY_ALL_UNITS;
+ if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS$_sys_service_mgr ) ||
+ ! _retrieve_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr;
then
all_unit_files=( ${${(f)"$(__systemctl list-unit-files)"}%% *} )
_systemctl_all_units
really_all_units=($_sys_all_units $all_unit_files)
_sys_really_all_units=(${(u)really_all_units})
- _store_cache SYS_REALLY_ALL_UNITS _sys_really_all_units
+ _store_cache SYS_REALLY_ALL_UNITS$_sys_service_mgr _sys_really_all_units
fi
}
@@ -330,13 +330,13 @@ _unit_types() {
}
_unit_properties() {
- if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES ) &&
- ! _retrieve_cache SYS_ALL_PROPERTIES;
+ if ( [[ ${+_sys_all_properties} -eq 0 ]] || _cache_invalid SYS_ALL_PROPERTIES$_sys_service_mgr ) ||
+ ! _retrieve_cache SYS_ALL_PROPERTIES$_sys_service_mgr;
then
_sys_all_properties=( ${${(M)${(f)"$(__systemctl show --all;
@rootlibexecdir@/systemd --dump-configuration-items)"}##[[:alnum:]]##=*}%%=*}
)
- _store_cache SYS_ALL_PROPRTIES _sys_all_properties
+ _store_cache SYS_ALL_PROPERTIES$_sys_service_mgr _sys_all_properties
fi
_values -s , "${_sys_all_properties[@]}"
}