zsh: _journalctl: also handle --root arg and --key=value style (#3956)
This will now also handle `journalctl --directory=/var/log/journal` properly.
This commit is contained in:
parent
ba89f80620
commit
b2fe35fe58
|
@ -54,16 +54,25 @@ _journal_boots() {
|
||||||
# Build arguments for "journalctl" to be used in completion.
|
# Build arguments for "journalctl" to be used in completion.
|
||||||
# Use both --user and --system modes, they are not exclusive.
|
# Use both --user and --system modes, they are not exclusive.
|
||||||
local -a _modes; _modes=(--user --system)
|
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
|
typeset -a _sys_service_mgr
|
||||||
local w i=0 n=$#words
|
local w k v i=0 n=$#words
|
||||||
while (( i++ < n )); do
|
while (( i++ < n )); do
|
||||||
w=$words[$i]
|
w=$words[$i]
|
||||||
if (( $_modes[(I)$w] )); then
|
if (( $_modes[(I)$w] )); then
|
||||||
_sys_service_mgr+=($w)
|
_sys_service_mgr+=($w)
|
||||||
else
|
else
|
||||||
if (( ${_modes_with_arg[(I)$w]} )); then
|
# Handle options with arguments. "--key=value" and "--key value".
|
||||||
_sys_service_mgr+=($w ${words[((++i))]})
|
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
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue