about summary refs log tree commit diff
path: root/Completion/Solaris/Command/_pfexec
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Solaris/Command/_pfexec')
-rw-r--r--Completion/Solaris/Command/_pfexec31
1 files changed, 31 insertions, 0 deletions
diff --git a/Completion/Solaris/Command/_pfexec b/Completion/Solaris/Command/_pfexec
new file mode 100644
index 000000000..227336223
--- /dev/null
+++ b/Completion/Solaris/Command/_pfexec
@@ -0,0 +1,31 @@
+#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() {
+ 	_arguments \
+		'-P[privileges to acquire]:privspec:_privset' \
+ 		'(-):command name: _command_names -e' \
+ 		'*::arguments: _normal'
+}
+
+_pfexec "$@"