zsh-workers
 help / color / mirror / code / Atom feed
2519c3cdc2615d729cf41c6b9564770ef3f3f5c8 blob 751 bytes (raw)

 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
 
#compdef pfexec

# This is a _values-like function that completes privileges and !-prefixed
# privileges, comma-separated, and unique.
_privset() {
	local expl p
	local -a privs

	privs=( ${(f)"$(ppriv -l)"} all none zone basic )

	# Ignore existing values
	compset -P '*,'
	# Ignore a leading !, maybe backslash-quoted
	compset -P '\\#!'

	# Remove already-referenced privs
	for p in ${(s:,:)${IPREFIX//\\#\!/}}; do
		privs=( ${privs:#$p} )
	done

	_wanted privs expl 'privilege' compadd -qS , -a privs
}

_pfexec() {
	local -a _comp_priv_prefix
 	_arguments \
		'-P[privileges to acquire]:privspec:_privset' \
 		'(-):command name: _command_names -e' \
		'*::arguments:{ _comp_priv_prefix=( pfexec ${(kv)opt_args[-P]} ) ; _normal }'
}

_pfexec "$@"
debug log:

solving 2519c3cdc ...
found 2519c3cdc in https://git.vuxu.org/mirror/zsh/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).