1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
| | #autoload
# Complete syslog-style priorities/facilities/levels
#
# Note: 'Priority' according to syslog(3) refers to a severity level optionally
# ORed with a facility. We use it here in a somewhat similar manner, as this
# seems to cover the most ground, though we also support completing facilities
# alone.
#
# By default, a case-insensitive facility.level pair is completed.
#
# Some tools that accept symbolic facility/level names also accept numbers
# corresponding to their associated values defined in syslog.h. Since these
# numbers vary across systems, we don't attempt to complete them.
#
# Options:
# -y Complete only facilities
# -Y Complete only severity levels
# -z Complete only lower-case names
# -Z Complete only upper-case names
local -a expl facilities levels ca_opts
local -A opts
# Facilities vary across systems too, but these seem common enough
facilities=(
kern
user
mail
daemon
auth
syslog
lpr
news
uucp
cron
authpriv
ftp
ntp
security
local{0..7}
)
levels=(
emerg # 'panic' is deprecated
alert
crit
err # 'error' is deprecated
warning # 'warn' is deprecated
notice
info
debug
)
zparseopts -A opts -D -E -- y Y z Z
if (( $+opts[-Z] )); then
facilities=( ${(@U)facilities} )
levels=( ${(@U)levels} )
elif (( ! $+opts[-z] )); then
ca_opts+=( -M 'm:{a-zA-Z}={A-Za-z}' )
fi
if (( $+opts[-Y] )) || { (( ! $+opts[-y] )) && compset -P '[^.]##.' }; then
_wanted levels expl 'log severity level' \
compadd -a "$@" "${(@)ca_opts}" - levels
else
(( ! $+opts[-y] )) && ! compset -S '.[^.]##' && ca_opts+=( -qS. )
_wanted facilities expl 'log facility' \
compadd -a "$@" "${(@)ca_opts}" - facilities
fi
|