75 lines
3.2 KiB
Diff
75 lines
3.2 KiB
Diff
From d8386bfd28676e1c6fd88deaf203eb1cd7585233 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?=
|
|
=?UTF-8?q?=D0=A2=D0=B8=D1=85=D0=BE=D0=BD=D0=BE=D0=B2?=
|
|
<disarmer.mk@gmail.com>
|
|
Date: Sat, 21 Jan 2017 23:53:09 +0400
|
|
Subject: [PATCH] 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
|
|
(cherry picked from commit 88e4dbd505ed4f8480b1f3b837b3c2ac55f1b1dd)
|
|
---
|
|
shell-completion/zsh/_systemctl.in | 18 +++++++++---------
|
|
1 file 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[@]}"
|
|
}
|