]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
zsh-completion: fix completion of --user services 4/head
authorEric Cook <llua@gmx.com>
Mon, 18 May 2015 22:45:31 +0000 (18:45 -0400)
committerHarald Hoyer <harald@redhat.com>
Mon, 18 May 2015 23:01:40 +0000 (01:01 +0200)
By the time __systemctl is called, --user/--system are shifted out of
`words' by _arguments. This patch queries the array sooner.

In the case that both --user and --system are on the line when compsys runs,
_sys_service_mgr is set to the latter. Which is seemingly how systemctl behaves.

If neither are on the line, --system is set; for system services to be completed.

shell-completion/zsh/_systemctl.in

index 1dc6406bebad900a1dde896a2698cda2b8efca57..db9bdb60c5653e8a0fa93bd1b9371ce3671cecdc 100644 (file)
@@ -93,9 +93,7 @@
 
 __systemctl()
 {
-  local -a _modes
-  _modes=("--user" "--system")
-  systemctl ${words:*_modes} --full --no-legend --no-pager "$@"
+  systemctl $_sys_service_mgr --full --no-legend --no-pager "$@"
 }
 
 
@@ -355,6 +353,8 @@ _job_modes() {
     _values -s , "${_modes[@]}"
 }
 
+local -a _modes; _modes=("--user" "--system")
+local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}
 _arguments -s \
     {-h,--help}'[Show help]' \
     '--version[Show package version]' \