blob: f0c12a2bed4dd100bbccbbe62f508928afe92f6b (
plain) (
blame)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#compdef sysrc
_sysrc_caching_policy() {
local -a oldp
oldp=( "$1"(Nm+1) )
(( $#oldp ))
}
_sysrc() {
local curcontext="$curcontext" state line ret=1
typeset -A opt_args
local -a rc_conf_vars
_arguments -C -s -A '-*' : \
'(-l)-e[print variables as sh(1) compatible syntax]' \
'-E[list only existing files]' \
'(-l)-q[quiet mode]' \
'(-L)-s+[process additional rc.conf.d entries for specified service name]:service name:_services' \
'(-L)*-f+[operate on specified file(s), not \`rc_conf_files'\'']: : _files' \
'(-l)-v[verbose mode]' \
'*:configuration variable:->confvars' \
- set \
'(-A)-a[list all non-default configuration variables]' \
'(-a)-A[list all configuration variables]' \
'-c[check only, return success if vars are set]' \
'-d[print variable(s) description]' \
'-D[print default value(s) only]' \
'-F[print only the last rc.conf(5) file each directive is in]' \
'(- *)-h[print short usage message]' \
'(- *)--help[print full usage message]' \
'-i[ignore unknown variables]' \
'-j+[jail to operate within]:jails:_jails' \
'-n[print only variable values]' \
'-N[print only variable names]' \
'-R+[specify an alternative root]:alternative root:_files -/' \
'(- *)--version[print version information]' \
'-x[remove specified variables from specified file(s)]' \
- lists \
'(-e -q -v)-l[list config files used at startup]' \
- lista \
'(-s -f)-L[list all configuration files including rc.conf.d entries]' && ret=0
if [[ $state == confvars ]]; then
local k v opt
if (( $+opt_args[lista--L] )); then
_services && ret=0
elif compset -P 1 '*='; then
case $IPREFIX in
*_enable=) _wanted values expl value compadd YES NO && ret=0 ;;
*_program=) _files -g "*(-*)" && ret=0 ;;
*_interface(|s)=) _net_interfaces && ret=0 ;;
*) _message -e values value ;;
esac
else
if zstyle -T ":completion:${curcontext%:*}:values" verbose; then
opt=d
else
opt=N
fi
if ! zstyle -m ":completion:${curcontext%:*}:values" cache-policy '*'; then
zstyle ":completion:${curcontext%:*}:values" cache-policy _sysrc_caching_policy
fi
if _cache_invalid sysrc/rc_conf_vars ||
! _retrieve_cache sysrc/rc_conf_vars; then
_call_program sysrc-cmd sysrc -A$opt | while read -r k v; do
[[ $k = DEBUG* ]] && continue
if [[ -z $v ]]; then
rc_conf_vars+=( ${k%:} )
else
rc_conf_vars+=( "${k%:}[${${v//]/\\]}//:/\\:}]" )
fi
v=
done
_store_cache sysrc/rc_conf_vars rc_conf_vars
fi
if (( $#rc_conf_vars )); then
if [[ $opt == N ]]; then
_values -w variable ${^rc_conf_vars%%\[*}'::value' && ret=0
else
_values -w variable ${^rc_conf_vars}'::value' && ret=0
fi
fi
fi
fi
return ret
}
_sysrc "$@"
|