summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hahler <github@thequod.de>2016-08-16 18:47:39 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-08-16 12:47:39 -0400
commitb2fe35fe58f5229c0a265c86877b5d08114a2867 (patch)
tree1b36893d869f0e2b20b089bbd73575daf6337bab
parentba89f80620d619867b4838973785d529c5a959f6 (diff)
zsh: _journalctl: also handle --root arg and --key=value style (#3956)
This will now also handle `journalctl --directory=/var/log/journal` properly.
-rw-r--r--shell-completion/zsh/_journalctl17
1 files changed, 13 insertions, 4 deletions
diff --git a/shell-completion/zsh/_journalctl b/shell-completion/zsh/_journalctl
index 610788dcce..ef67fcf2a0 100644
--- a/shell-completion/zsh/_journalctl
+++ b/shell-completion/zsh/_journalctl
@@ -54,16 +54,25 @@ _journal_boots() {
# Build arguments for "journalctl" to be used in completion.
# Use both --user and --system modes, they are not exclusive.
local -a _modes; _modes=(--user --system)
-local -a _modes_with_arg; _modes_with_arg=(--directory -D --file -M --machine)
+local -a _modes_with_arg; _modes_with_arg=(--directory -D --file -M --machine --root)
typeset -a _sys_service_mgr
-local w i=0 n=$#words
+local w k v i=0 n=$#words
while (( i++ < n )); do
w=$words[$i]
if (( $_modes[(I)$w] )); then
_sys_service_mgr+=($w)
else
- if (( ${_modes_with_arg[(I)$w]} )); then
- _sys_service_mgr+=($w ${words[((++i))]})
+ # Handle options with arguments. "--key=value" and "--key value".
+ k=${w%%=*}
+ if (( ${_modes_with_arg[(I)$k]} )); then
+ v=${w#*=}
+ if [[ "$k" != "$w" ]]; then
+ # "--key=value" style.
+ _sys_service_mgr+=($w)
+ else
+ # "--key value" style.
+ _sys_service_mgr+=($w ${words[((++i))]})
+ fi
fi
fi
done