]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
zsh: _systemctl: do not attempt to use "--system" by default (#3951)
authorDaniel Hahler <github@thequod.de>
Sat, 13 Aug 2016 14:42:55 +0000 (16:42 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 13 Aug 2016 14:42:55 +0000 (10:42 -0400)
In 68c4f6d the following was added:

    local -a _modes; _modes=("--user" "--system")
    local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}

With the following comment:

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

But it does not work as documented:

    % _modes=(--user --system)
    % words=()
    % echo ${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}

However, it should not use `--system` in that case anyway, so this patch
removes the part that should cause a default to be used and adds some
comments.

shell-completion/zsh/_systemctl.in

index 69f643303dc527ed1905442ab85697910fb3d7b4..b52528693255b7455375e994355e46d6f7ebb28e 100644 (file)
@@ -351,8 +351,10 @@ _job_modes() {
     _values -s , "${_modes[@]}"
 }
 
+# Build arguments for "systemctl" to be used in completion.
 local -a _modes; _modes=("--user" "--system")
-local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}
+# Use the last mode (they are exclusive and the last one is used).
+local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]}
 _arguments -s \
     {-h,--help}'[Show help]' \
     '--version[Show package version]' \