Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Solaris-specific completion directory?



On Mon, Jul 21, 2008 at 10:17:11AM -0700, Danek Duvall wrote:

> On Mon, Jul 21, 2008 at 09:30:52AM +0100, Peter Stephenson wrote:
> 
> > That would be fine:  I don't know which of those goes where but if the
> > solution you gave seems plausible I'm happy with it.
> 
> Here's the patch, then.  It's against 4.3.6, but that shouldn't make any
> difference.  Let me know if you want one against CVS.

Ugh, I pooched that, and put things in the wrong directories.  Here's one
that actually works.  Sorry 'bout that.

diff -urN Completion/Solaris/Command/_coreadm Completion/Solaris/Command/_coreadm
--- Completion/Solaris/Command/_coreadm	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_coreadm	2005-11-04 15:08:07.000000000 -0800
@@ -0,0 +1,48 @@
+#compdef coreadm
+
+_coreadm() {
+	local -a content option
+
+	content=(
+		"anon[Anonymous private mappings]"
+		"ctf[CTF type information]"
+		"data[Writable private file mappings]"
+		"dism[DISM mappings]"
+		"heap[Process heap]"
+		"ism[ISM mappings]"
+		"rodata[Read-only private file mappings]"
+		"shanon[Anonymous shared mappings]"
+		"shfile[File-backed shared mappings]"
+		"shm[System V shared memory]"
+		"stack[Process stack]"
+		"symtab[Symbol table sections for loaded files]"
+		"text[Readable and executable private file mappings]"
+	)
+
+	option=(
+		"global"\:"Allow global core dumps"
+		"global-setid"\:"Allow set-id global core dumps"
+		"log"\:"Generate a syslog message on global core dump"
+		"process"\:"Allow per-process core dumps"
+		"proc-setid"\:"Allow set-id per-process core dumps"
+	)
+
+	# _values doesn't quite work for us here -- the separator can be either
+	# "+" or "-"
+	_arguments -s \
+		- set1 \
+		'-g[Global core file name pattern]:' \
+		'-G[Global core file content]:content:_values -s + "content" $content' \
+		'-i[Per-process core file name pattern]:' \
+		'-I[Per-process core file content]:content:_values -s + "content" $content' \
+		'*-d[Disable core option]:option:(($option))' \
+		'*-e[Enable core option]:option:(($option))' \
+		- set2 \
+		'-p[PID-specific per-process core file name pattern]:' \
+		'-P[PID-specific per-process core file content]:content:_values -s + "content" $content' \
+		'*:pids:_pids' \
+		- set3 \
+		'-u[Update options from coreadm.conf]'
+}
+
+_coreadm "$@"
diff -urN Completion/Solaris/Command/_dhcpinfo Completion/Solaris/Command/_dhcpinfo
--- Completion/Solaris/Command/_dhcpinfo	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_dhcpinfo	2007-10-01 22:58:52.000000000 -0700
@@ -0,0 +1,36 @@
+#compdef dhcpinfo
+
+_dhcpinfo() {
+	local -a mnemonics_v4 mnemonics_v6
+
+	mnemonics_v4=(
+		Subnet UTCoffst Router Timeserv IEN116ns DNSserv Logserv
+		Cookie Lprserv Impress Resource Hostname Bootsize Dumpfile
+		DNSdmain Swapserv Rootpath ExtendP IpFwdF NLrouteF PFilter
+		MaxIpSiz IpTTL PathTO PathTbl MTU SameMtuF Broadcst
+		MaskDscF MaskSupF RDiscvyF RSolictS StaticRt TrailerF
+		ArpTimeO EthEncap TcpTTL TcpKaInt TcpKaGbF NISdmain
+		NISservs NTPservs NetBNms NetBDsts NetBNdT NetBScop
+		XFontSrv XDispMgr LeaseTim Message T1Time T2Time NW_dmain
+		NWIPOpts NIS+dom NIS+serv TFTPsrvN OptBootF MblIPAgt
+		OptBootF MblIPAgt SMTPserv POP3serv NNTPserv WWWservs
+		Fingersv IRCservs STservs STDAservs UserClas SLP_DA SLP_SS
+		AgentOpt FQDN PXEarch BootFile BootPath BootSrvA BootSrvN
+		EchoVC LeaseNeg
+	)
+
+	mnemonics_v6=(
+		ClientID ServerID Preference Unicast UserClass VendorClass
+		SIPNames SIPAddresses DNSAddresses DNSSearch NISServers
+		NIS+Servers NISDomain NIS+Domain SNTPServers InfoRefresh
+		BCMCDomain BCMCAddresses
+	)
+
+	_arguments -A \
+		'-c[]' \
+		'-i[Interface]:interface:' \
+		'-n[Maximum number of lines]:limit:' \
+		':DHCP Parameter:_values "DHCP Parameter" $mnemonics_v4' \
+}
+
+_dhcpinfo "$@"
diff -urN Completion/Solaris/Command/_dumpadm Completion/Solaris/Command/_dumpadm
--- Completion/Solaris/Command/_dumpadm	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_dumpadm	2005-11-04 15:30:58.000000000 -0800
@@ -0,0 +1,23 @@
+#compdef dumpadm
+
+_dumpadm() {
+	local -a content
+
+	content=(
+		"kernel"\:"Kernel memory pages only"
+		"all"\:"All memory pages"
+		"curproc"\:"Kernel memory pages plus curproc pages"
+	)
+
+	_arguments -s \
+		'-n[Dont run savecore on reboot]' \
+		'-u[Update dump configuration from dumpadm.conf]' \
+		'-y[Run savecore on reboot]' \
+		'-c[Set dump content]:dump content:(($content))' \
+		'-d[Set dump device]:block devices:_files -g "*(-%b)"' \
+		'-m[Set minfree size ]:' \
+		'-s[Set the savecore directory]:directory:_files -/' \
+		'-r[Alternate root directory]:directory:_files -/'
+}
+
+_dumpadm "$@"
diff -urN Completion/Solaris/Command/_gcore Completion/Solaris/Command/_gcore
--- Completion/Solaris/Command/_gcore	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_gcore	2005-11-04 15:07:37.000000000 -0800
@@ -0,0 +1,31 @@
+#compdef gcore
+
+_gcore() {
+	local -a content
+
+	content=(
+		"anon[Anonymous private mappings]"
+		"ctf[CTF type information]"
+		"data[Writable private file mappings]"
+		"dism[DISM mappings]"
+		"heap[Process heap]"
+		"ism[ISM mappings]"
+		"rodata[Read-only private file mappings]"
+		"shanon[Anonymous shared mappings]"
+		"shfile[File-backed shared mappings]"
+		"shm[System V shared memory]"
+		"stack[Process stack]"
+		"symtab[Symbol table sections for loaded files]"
+		"text[Readable and executable private file mappings]"
+	)
+
+	_arguments -s \
+		'-p[Use per-process core file repository]' \
+		'-g[Use global core file repository]' \
+		'-F[Force grabbing the target process]' \
+		'-c[Set core file content]:_values -s + "content" $content' \
+		'-o[Set core file base name]:' \
+		'*:pids:_pids'
+}
+
+_gcore "$@"
diff -urN Completion/Solaris/Command/_inetadm Completion/Solaris/Command/_inetadm
--- Completion/Solaris/Command/_inetadm	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_inetadm	2005-11-04 01:32:28.000000000 -0800
@@ -0,0 +1,16 @@
+#compdef inetadm
+
+_inetadm() {
+	_arguments -s \
+		'-?[Help]' \
+		'-l[List service instance properties]:FMRI:_svcs_fmri -i' \
+		'-e[Enable specified instance]:FMRI:_svcs_fmri -i' \
+		'-d[Disable specified instance]:FMRI:_svcs_fmri -i' \
+		'-p[List inet service properties]' \
+		'-m[Modify service instance properties]:FMRI:_svcs_fmri -i' \
+		'-M[Modify inet service properties]'
+}
+
+_inetadm "$@"
+
+# vi:tw=0
diff -urN Completion/Solaris/Command/_pfexec Completion/Solaris/Command/_pfexec
--- Completion/Solaris/Command/_pfexec	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_pfexec	2007-09-24 08:41:45.000000000 -0700
@@ -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 "$@"
diff -urN Completion/Solaris/Command/_ptree Completion/Solaris/Command/_ptree
--- Completion/Solaris/Command/_ptree	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_ptree	2005-12-13 11:01:24.000000000 -0800
@@ -0,0 +1,23 @@
+#compdef ptree
+
+_ptree() {
+	local curcontext="$curcontext" context state line ret=1
+	typeset -A opt_args
+
+	_arguments -s \
+		'-a[All processes]' \
+		'-c[Show contract memberships]' \
+		'-z[Show processes in zone]:zone:($(zoneadm list))' \
+		'*:pid or user:->pidoruser' && ret=0
+
+	if [[ $ret -ne 0 ]]; then
+		_alternative \
+			'users:logged-in user:(${$(who -q)\:#(users=*|\#)})' \
+			'pids:pid:_pids'
+		ret=$?
+	fi
+
+	return $ret
+}
+
+_ptree "$@"
diff -urN Completion/Solaris/Command/_savecore Completion/Solaris/Command/_savecore
--- Completion/Solaris/Command/_savecore	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_savecore	2005-11-04 15:34:56.000000000 -0800
@@ -0,0 +1,12 @@
+#compdef savecore
+
+_savecore() {
+	_arguments -s \
+		'-L[Take live dump]' \
+		'-v[Verbose]' \
+		'-d[Disregard dump header valid flag]' \
+		'-f[Save crash dump from file]:file:_files' \
+		'::directory:_files -/'
+}
+
+_savecore "$@"
diff -urN Completion/Solaris/Command/_svcadm Completion/Solaris/Command/_svcadm
--- Completion/Solaris/Command/_svcadm	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_svcadm	2005-11-03 20:11:37.000000000 -0800
@@ -0,0 +1,70 @@
+#compdef svcadm
+
+_svcadm() {
+	local context state line subcmds
+	typeset -A opt_args
+
+	subcmds=( enable disable restart refresh mark clear milestone )
+
+	if [[ $service == "svcadm" ]]; then
+		_arguments -C -A "-*" \
+			'-v[Print actions verbosely]' \
+			'*::command:->subcmd' && return 0
+
+		if (( CURRENT == 1 )); then
+			_wanted commands expl 'svcadm subcommand' compadd -a subcmds
+			return
+		fi
+		service="$words[1]"
+		curcontext="${curcontext%:*}=$service:"
+	fi
+
+	case $service in
+	(enable)
+		_arguments \
+			'-r[Recursively enable dependencies]' \
+			'-s[Wait for service to come online]' \
+			'-t[State change is temporary]' \
+			'*:instance FMRI:_svcs_fmri -i'
+		;;
+
+	(disable)
+		_arguments \
+			'-s[Wait for service to become disabled]' \
+			'-t[State change is temporary]' \
+			'*:instance FMRI:_svcs_fmri -i'
+		;;
+
+	(mark)
+		_arguments \
+			'-I[Change state immediately]' \
+			'-t[State change is temporary]' \
+			':state:(degraded maintenance)' \
+			':instance FMRI:_svcs_fmri -i'
+		;;
+
+	(restart|refresh|clear)
+		_arguments \
+			'*:instance FMRI:_svcs_fmri -i'
+		;;
+
+	(milestone)
+		_arguments \
+			'-d[Make milestone the default]' \
+			'*:milestone FMRI:_svcs_fmri -m'
+		;;
+
+# 	# The delegate subcommand has been removed, replaced by just using
+# 	# the restarter fmri
+# 	(delegate)
+# 		_arguments \
+# 			'1:restarter FMRI:_svcs_fmri -r' \
+# 			'*:instance FMRI:_svcs_fmri -i'
+# 		;;
+
+	(*)
+		_message "unknown svcadm subcommand: $service"
+	esac
+}
+
+_svcadm "$@"
diff -urN Completion/Solaris/Command/_svccfg Completion/Solaris/Command/_svccfg
--- Completion/Solaris/Command/_svccfg	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_svccfg	2005-11-03 20:54:19.000000000 -0800
@@ -0,0 +1,58 @@
+#compdef svccfg
+
+_svccfg() {
+	local context state line subcmds
+
+	subcmds=( apply extract import validate export inventory delete addpropvalue delpropvalue )
+
+	if [[ $service == "svccfg" ]]; then
+		_arguments -s \
+			'-?[Help]' \
+			'-v[Verbose]' \
+			'-s[FMRI on which to operate]:fmri:_svcs_fmri -c' \
+			- set1 \
+			'-f[Read commands from file]:command file:_files' \
+			- set2 \
+			'*::command:->subcmd' && return 0
+
+		if (( CURRENT == 1 )); then
+			_wanted commands expl 'svccfg subcommand' compadd -a subcmds
+			return
+		fi
+		service="$words[1]"
+		curcontext="${curcontext%:*}=$service:"
+	fi
+
+	case $service in
+	(import)
+		_arguments \
+			'-V[Verify property updates]' \
+			':file:_files'
+		;;
+
+	(apply|validate|inventory)
+		_files
+		;;
+
+	(export)
+		_svcs_fmri -c
+		;;
+
+	(delete)
+		_arguments \
+			'-f[Force deletion if online or degraded]' \
+			'*:FMRI:_svcs_fmri -c'
+		;;
+
+	(extract)
+		;;
+
+	(*)
+		_message "unknown svccfg subcommand: $service"
+		;;
+	esac
+}
+
+_svccfg "$@"
+
+# vi:tw=0
diff -urN Completion/Solaris/Command/_svcprop Completion/Solaris/Command/_svcprop
--- Completion/Solaris/Command/_svcprop	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_svcprop	2005-11-03 20:22:57.000000000 -0800
@@ -0,0 +1,23 @@
+#compdef svcprop
+
+_svcprop() {
+	_arguments -s \
+		'-f[Designate properties by their FMRI]' \
+		'-q[Quiet]' \
+		'-t[Use multi-property output format]' \
+		'-v[Verbose]' \
+		- set1 \
+		'-w[Waits for the selected property or property group to change]' \
+		'-p[Prints values of named property or property group]' \
+		':FMRI:_svcs_fmri -i' \
+		- set2 \
+		'(-c -s)-C[Retrieve properties without composition]' \
+		'(-C -s)-c[Retrieve properties with composition]' \
+		'(-c -C)-s[Retrieve properties from snapshot]:snapshot:' \
+		'*-p[Prints values of named property or property group]' \
+		'*:FMRI:_svcs_fmri -i'
+}
+
+_svcprop "$@"
+
+# vi:tw=0
diff -urN Completion/Solaris/Command/_svcs Completion/Solaris/Command/_svcs
--- Completion/Solaris/Command/_svcs	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_svcs	2004-09-21 07:18:47.000000000 -0700
@@ -0,0 +1,32 @@
+#compdef svcs
+
+_svcs() {
+	local -a cols
+
+	cols=(
+		ctid\:"Contract ID" desc\:"Description" fmri\:"FMRI"
+		inst\:"Instance name" nsta\:"Next state (abbr)" nstate\:"Next state"
+		scope\:"Scope name" svc\:"Service name" sta\:"State (abbr)"
+		state\:"State" stime\:"Start time"
+	)
+
+	_arguments -s \
+		'(-l -x -d -D)-a[List all instances]' \
+		'(-l -x -D -a -R)-d[List dependencies]' \
+		'(-l -x -d -a -R)-D[List dependents]' \
+		'(-l -x)-H[Suppress header line]' \
+		'(-)-l[Print detailed status about services and instances]' \
+		'(-l -x)-o[Display specific columns]:column:_values -s , "column" ${^cols/\:/[}\]' \
+		'(-l -x)-p[List processes]' \
+		'(-l -x -d -D)-R[List services with the given restarter]:instance FMRI:_svcs_fmri -i' \
+		'(-l -x)-s[Sort by a column]:column:(($cols))' \
+		'(-l -x)-S[Reverse sort by a column]:column:(($cols))' \
+		'(-l)-v[verbose columns]' \
+		'(-l)-x[Display explanation for service states]' \
+		'(-l -x)-\?[Print help]' \
+		'*:FMRI or pattern:_svcs_fmri -i'
+}
+
+_svcs "$@"
+
+# vi:tw=0
diff -urN Completion/Solaris/Type/_svcs_fmri Completion/Solaris/Type/_svcs_fmri
--- Completion/Solaris/Type/_svcs_fmri	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Type/_svcs_fmri	2007-10-27 18:09:21.000000000 -0700
@@ -0,0 +1,82 @@
+#autoload
+
+_svcs_fmri() {
+	local type="$argv[$#]"
+	local fmri_abbrevs m i
+	typeset -a -g _smf_fmris
+
+	local update_policy
+	zstyle -s ":completion:${curcontext}:" cache-policy update_policy
+	if [[ -z "$update_policy" ]]; then
+		zstyle ":completion:${curcontext}:" cache-policy _smf_caching_policy
+	fi
+	# The cache really must be per-host
+	local cache_id=smf_fmri:$HOST
+
+	# TODO: Do something useful with the expand and/or ambiguous styles.
+	case $type in
+	(-i|-c)
+		# We probably also need an option to eliminate ambiguous
+		# results for use in places where that's not allowed.
+
+		# Grab all FMRIs that have a word beginning with $PREFIX,
+		# making sure not to return the portion of the FMRI before
+		# $PREFIX.  Use the cache if it exists and the user wants to.
+		if ( [[ $#_smf_fmris -eq 0 ]] || _cache_invalid $cache_id ) && ! _retrieve_cache $cache_id; then
+			_smf_fmris=( ${(f)"$(svcs -a -H -o fmri)"} )
+			_store_cache $cache_id _smf_fmris
+		fi
+		# Each element of the array is removed which doesn't match (^|.*/)$PREFIX.*
+		fmri_abbrevs=( ${(M)_smf_fmris:#((#s)|*[/:])$PREFIX*} )
+
+		# Go through the remaining elements and remove the characters
+		# in front of $PREFIX.
+		for i in {1..$#fmri_abbrevs}; do
+			# Either one of these will work, but they're too
+			# greedy, preventing multiple matches below.
+			fmri_abbrevs[i]=${${fmri_abbrevs[i]}/((#s)|*[\/:])(#b)($PREFIX*)/$match[1]}
+			#fmri_abbrevs[i]=${${(M)${fmri_abbrevs[i]}:#(#b)((#s)|*/)$PREFIX*}#$match[1]}
+		done
+
+		# Remove the "default" instance identifier if we can (not for
+		# svccfg)
+		# TODO Can't remove default when there are other instances.
+		if [[ $type == "-i" ]]; then
+			fmri_abbrevs=( ${fmri_abbrevs//:default(#e)/} )
+		fi
+
+		# Search for a second match within each result.
+		# for m in $fmri_abbrevs; do
+		# 	if [[ -n ${(M)m:#((#s)|*/)$PREFIX*/$PREFIX*} ]]; then
+		# 		fmri_abbrevs=( $fmri_abbrevs ${${(SMI:1:)m%%/$PREFIX*}#/} )
+		# 	fi
+		# done
+
+		# After playing with _multi_parts, I'm not sure it's actually that useful.
+		# _wanted fmri expl "full or unambiguously abbreviated FMRIs" _multi_parts / fmri_abbrevs
+		_wanted fmri expl "full or unambiguously abbreviated FMRIs" compadd $fmri_abbrevs
+		;;
+
+	(-m)
+		_wanted fmri expl "milestone FMRIs" \
+			compadd $(svcs -H -o fmri svc:/milestone/\*) all
+		;;
+
+	(-r)
+		# TODO: need some way to pick out only restarters
+		_wanted fmri expl "restarter FMRIs" compadd master svc:/network/inetd:default
+		;;
+
+	(*)
+		_message "unknown argument to _svcs_fmri: $type"
+		;;
+	esac
+}
+
+_smf_caching_policy() {
+	# /etc/svc/repository.db is not a public interface, so this is kinda
+	# grody.
+	[[ ! -f "$1" || /etc/svc/repository.db -nt "$1" ]]
+}
+
+_svcs_fmri "$@"
diff -urN Completion/Solaris/Command/_zlogin Completion/Solaris/Command/_zlogin
--- Completion/Solaris/Command/_zlogin	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Solaris/Command/_zlogin	2005-11-04 19:36:22.000000000 -0800
@@ -0,0 +1,16 @@
+#compdef zlogin
+
+_zlogin() {
+	_arguments -s \
+		'-E[Disable escape character]' \
+		'-e[Specify escape character]:character:' \
+		'-l[Specify username]:username:_users' \
+		':zonename:' \
+		- set1 \
+		'-C[Connect to zone console]' \
+		- set2 \
+		'-S["Safe" login mode]' \
+		':utility'
+}
+
+_zlogin "$@"
diff -urN Completion/Unix/Type/_pkg_instance Completion/Unix/Type/_pkg_instance
--- Completion/Unix/Type/_pkg_instance	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Type/_pkg_instance	2005-11-03 17:45:18.000000000 -0800
@@ -0,0 +1,20 @@
+#autoload
+
+local -A opts
+local whicharg
+
+zparseopts -E -D -- '-_opts:=opts'
+
+whicharg=${opts#*:}
+
+case ${opts%:*} in
+(installed)
+	compadd "$@" - ${opt_args[$whicharg]}/var/sadm/pkg/*/pkginfo(:h:t)
+	;;
+(spooled)
+	compadd "$@" - ${opt_args[$whicharg]}/*(:t)
+	;;
+(uninstalled)
+	compadd "$@" - ${opt_args[$whicharg]:-/var/spool/pkg}/*/pkgmap(:h:t)
+	;;
+esac
diff -urN Completion/Unix/Command/_pkgadd Completion/Unix/Command/_pkgadd
--- Completion/Unix/Command/_pkgadd	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Command/_pkgadd	2004-09-29 00:14:56.000000000 -0700
@@ -0,0 +1,32 @@
+#compdef pkgadd
+
+_pkgadd_pass() {
+	_values -S : 'password descriptor' \
+	'(file env console)pass[Literal password]:password:' \
+	'(pass file console)env[Environment variable]:environment:_parameters -g "*export*"' \
+	'(pass env console)file[File]:file:_files' \
+	'(pass env file)console[From /dev/tty]'
+}
+
+_pkgadd() {
+	_arguments -s \
+	'-d[Device]:device file:_files' \
+	'-x[HTTP(S) proxy]:HTTP proxy: ' \
+	'-k[Keystore]:keystore:_files' \
+	'-P[Password to decrypt keystore]:password:_pkgadd_pass' \
+	'-Y[Select packages by category]:category: ' \
+	- set1 \
+	'-n[Non-interactive mode]' \
+	'-v[Trace all scripts]' \
+	'-a[Admin file]:admin file:_files' \
+	"-M[Don't use vfstab file]" \
+	'-R[Root path]:root path:_files -/' \
+	'-r[Response file]:response file:_files' \
+	'-V[Alternate vfstab file]:vfstab file:_files' \
+	'*:package instance:_pkg_instance --_opts uninstalled:-d' \
+	- set2 \
+	'-s[Spool package]:spool directory:_files -/' \
+	'*:package instance:_pkg_instance --_opts uninstalled:-d'
+}
+
+_pkgadd "$@"
diff -urN Completion/Unix/Command/_pkginfo Completion/Unix/Command/_pkginfo
--- Completion/Unix/Command/_pkginfo	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Command/_pkginfo	2004-09-29 00:12:05.000000000 -0700
@@ -0,0 +1,22 @@
+#compdef pkginfo
+
+_pkginfo() {
+	_arguments -s \
+	'(-q -r -x)-l[Long listing]' \
+	'(-l -r -x)-q[Quiet mode]' \
+	'(-l -q -x)-r[Relocation base]' \
+	'(-l -q -r)-x[Extracted listing]' \
+	'-c[Category]:category: ' \
+	'-a[Architecture]:architecture: ' \
+	'-v[Version]:version: ' \
+	- set1 \
+	'(-p)-i[Select completely installed packages]' \
+	'(-i)-p[Select partially installed packages]' \
+	'-R[Root path]:root path:_files -/' \
+	'*:package instance:_pkg_instance --_opts installed:set1--R' \
+	- set2 \
+	'-d[Device]:device file:_files' \
+	'*:package instance:_pkg_instance --_opts uninstalled:set2--d'
+}
+
+_pkginfo "$@"
diff -urN Completion/Unix/Command/_pkgrm Completion/Unix/Command/_pkgrm
--- Completion/Unix/Command/_pkgrm	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Command/_pkgrm	2004-09-29 00:16:37.000000000 -0700
@@ -0,0 +1,20 @@
+#compdef pkgrm
+
+_pkgrm() {
+	_arguments -s \
+	'-Y[Select packages by category]:category: ' \
+	- set1 \
+	'-n[Non-interactive mode]' \
+	'-v[Trace all scripts]' \
+	'-a[Admin file]:admin file:_files' \
+	"-A[Force removal of all files]" \
+	"-M[Don't use vfstab file]" \
+	'-R[Root path]:root path:_files -/' \
+	'-V[Alternate vfstab file]:vfstab file:_files' \
+	'*:package instance:_pkg_instance --_opts installed:set1--R' \
+	- set2 \
+	'-s[Spool package]:spool directory:_files -/' \
+	'*:package instance:_pkg_instance --_opts spooled:set2--s'
+}
+
+_pkgrm "$@"
diff -urN Completion/Unix/Command/_zfs Completion/Unix/Command/_zfs
--- Completion/Unix/Command/_zfs	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Command/_zfs	2007-09-23 14:05:01.000000000 -0700
@@ -0,0 +1,238 @@
+#compdef zfs
+
+_zfs() {
+	local context state line expl
+	typeset -A opt_args
+	local -a subcmds rw_properties rw_propnames ro_properties
+
+	subcmds=(
+		"create" "destroy" "clone" "promote" "rename" "snapshot"
+		"rollback" "list" "set" "get" "inherit" "mount" "unmount"
+		"share" "unshare" "send" "receive" "allow" "unallow"
+		"upgrade"
+	)
+
+	ro_properties=(
+		"name" "type" "creation" "used" "available" "referenced"
+		"compressratio" "mounted" "origin"
+	)
+
+	# TODO: Be cleverer about what values can be set.  Is there any way to
+	# set the sorting for *size properties to false by default?
+	rw_properties=(
+		"aclinherit:value:(discard noallow secure passthrough)"
+		"aclmode:value:(discard groupmask passthrough)"
+		"atime:value:(on off)"
+		"canmount:value:(on off)"
+		"checksum:value:(on off fletcher2 fletcher4 sha256)"
+		"compression:value:(on off lzjb gzip gzip-{1..9})"
+		"copies:value:(1 2 3)"
+		"devices:value:(on off)"
+		"exec:value:(on off)"
+		"mountpoint:value:{if [[ -prefix /* ]]; then _path_files -/; else _wanted mountpoints expl 'mountpoint (type \"/\" to start completing paths)' compadd legacy none; fi}"
+		"quota:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == quota= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'quota' compadd none; fi}"
+		"readonly:value:(on off)"
+		"recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K)"
+		"reservation:value:" # <size>, "none"
+		"setuid:value:(on off)"
+		"shareiscsi:value:(on off)" # or "type=<type>"
+		"sharenfs:value:(on off)" # or share(1M) options
+		"snapdir:value:(hidden visible)"
+		"version:value:(1 2 current)"
+		"volblocksize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K)"
+		"volsize:value:" # <size>
+		"xattr:value:(on off)"
+		"zoned:value:(on off)"
+	)
+
+	rw_propnames=( ${rw_properties%%:*} )
+
+	if [[ $service == "zfs" ]]; then
+		_arguments -C -A "-*" \
+			'-\?[Help]' \
+			'*::command:->subcmd' && return 0
+
+		if (( CURRENT == 1 )); then
+			_wanted commands expl "zfs subcommand" compadd -a subcmds
+			return
+		fi
+		service="$words[1]"
+		curcontext="${curcontext%:*}=$service:"
+	fi
+
+	case $service in
+	("create")
+		_arguments -A "-*" \
+			'-p[Create parent datasets]' \
+			'-o[Set initial properties]:property:_values -s , "property" $rw_properties' \
+			- set1 \
+			':filesystem:' \
+			- set2 \
+			'-s[Create sparse volume]' \
+			'-b[Set volblocksize]:blocksize:' \
+			'-V[Set size]:size:' \
+			':volume:'
+		;;
+
+	("destroy")
+		_arguments -A "-*" \
+			'-r[Recursively destroy all children]' \
+			'-R[Recursively destroy all dependents]' \
+			'-f[Force unmounts]' \
+			':filesystem/volume/snapshot:_zfs_dataset'
+		;;
+
+	("snapshot")
+		_arguments -A "-*" \
+			'-r[Recursively snapshot all descendant datasets]' \
+			':filesystem/volume:_zfs_dataset -t fs -t vol -S@'
+		;;
+
+	("rollback")
+		_arguments -A "-*" \
+			'-r[Recursively destroy more recent snapshots]' \
+			'-R[Recursively destroy more recent snapshots and clones]' \
+			'-f[Force unmounts]' \
+			':snapshot:_zfs_dataset -t snap'
+		;;
+
+	("clone")
+		_arguments -A "-*" \
+			'-p[Create parent datasets]' \
+			# XXX needs to bail if there are no snapshots
+			':snapshot:_zfs_dataset -t snap' \
+			':filesystem/volume:'
+		;;
+
+	("promote")
+		# XXX complete only cloned filesystems
+		_arguments \
+			':filesystem:_zfs_dataset -t fs' \
+		;;
+
+	("rename")
+		_arguments -A "-*" \
+			- set1 \
+			'-p[Create parent datasets]' \
+			':filesystem/volume/snapshot:_zfs_dataset' \
+			':filesystem/volume/snapshot:' \
+			- set2 \
+			'-r[Recursively rename snapshots of all descendent datasets]' \
+			':snapshot:_zfs_dataset -t snap' \
+			':snapshot:'
+		;;
+
+	("list")
+		_arguments -A "-*" \
+			'-r[Recursively display children]' \
+			'-H[Scripting mode]' \
+			'-o[Properties to list]:property:_values -s , "property" $ro_properties $rw_propnames' \
+			'*-s[Sort key (ascending)]:property:_values "property" $ro_properties $rw_propnames' \
+			'*-S[Sort key (descending)]:property:_values "property" $ro_properties $rw_propnames' \
+			'-t[Dataset types to list]:dataset type:_values -s , "dataset type" filesystem snapshot volume' \
+			'*:filesystem/volume/snapshot:_zfs_dataset'
+		;;
+
+	("set")
+		_arguments \
+			':property:_values -s , "property" $rw_properties' \
+			'*:filesystem/volume:_zfs_dataset -t fs -t vol'
+		;;
+
+	("get")
+		_arguments -A "-*" \
+			"-r[Recursively display children's properties]" \
+			'-H[Scripting mode]' \
+			'-p[Display numbers exactly]' \
+			'-s[Specify sources]:source:_values -s , "source" local default inherited temporary none' \
+			'-o[Specify fields]:field:_values -s , "field" name property value source' \
+			':property:_values -s , "property" $ro_properties $rw_propnames all' \
+			'*:filesystem/volume/snapshot:_zfs_dataset'
+		;;
+
+	("inherit")
+		_arguments -A "-*" \
+			'-r[Recursively inherit property for all children]' \
+			':property:_values -s , "property" $ro_properties $rw_properties' \
+			'*:filesystem/volume:_zfs_dataset -t fs -t vol'
+		;;
+
+	("mount")
+		_arguments -A "-*" \
+			'-o[Mount options]:mount options:_values -s , "option" {,no}{devices,exec,setuid} ro rw' \
+			'-O[Overlay mount]' \
+			'-v[Report mount progress]' \
+			- set1 \
+			':filesystem:_zfs_dataset -t fs' \
+			- set2 \
+			'-a[Mount all available ZFS filesystems]'
+		;;
+
+	("unmount")
+		_arguments -A "-*" \
+			- set1 \
+			'-f[Force unmount]' \
+			':filesystem:_zfs_dataset -t fs -t mtpt' \
+			- set2 \
+			'-a[Unmount all ZFS filesystems]'
+		;;
+
+	("share")
+		_arguments -A "-*" \
+			- set1 \
+			'-a[Share all available ZFS filesystems]' \
+			- set2 \
+			':filesystem:_zfs_dataset -t fs'
+		;;
+
+	("unshare")
+		_arguments -A "-*" \
+			- set1 \
+			'-a[Unshare all shared ZFS filesystems]' \
+			- set2 \
+			'-F[Force unshare]' \
+			':filesystem:_zfs_dataset -t fs -t mtpt'
+		;;
+
+	("send")
+		_arguments -A "-*" \
+			'-i[Generate an incremental stream]:snapshot:_zfs_dataset -t snap' \
+			':snapshot:_zfs_dataset -t snap'
+		;;
+
+	("receive")
+		_arguments -A "-*" \
+			'-v[Verbose]' \
+			'-n[Do not receive the stream]' \
+			'-F[Force a rollback if necessary]' \
+			- set1 \
+			':filesystem/volume/snapshot:_zfs_dataset' \
+			- set2 \
+			'-d[Set path prefix]:filesystem:_zfs_dataset -t fs'
+		;;
+
+	("allow"|"unallow")
+		_message "unimplemented zfs subcommand: $service"
+		;;
+
+	("upgrade")
+		_arguments -A "-*" \
+			- set1 \
+			'-v[Verbose]' \
+			- set2 \
+			'-a[Upgrade all filesystems on all pools]' \
+			'-r[Upgrade descendent filesystems, too]' \
+			'-V[Upgrade to specified version]:version:(1 2)' \
+			- set3 \
+			'-r[Upgrade descendent filesystems, too]' \
+			'-V[Upgrade to specified version]:version:(1 2)' \
+			':filesystem:_zfs_dataset -t fs' \
+		;;
+
+	(*)
+		_message "unknown zfs subcommand: $service"
+		;;
+	esac
+}
+
+_zfs "$@"
diff -urN Completion/Unix/Type/_zfs_dataset Completion/Unix/Type/_zfs_dataset
--- Completion/Unix/Type/_zfs_dataset	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Type/_zfs_dataset	2007-09-15 22:14:47.000000000 -0700
@@ -0,0 +1,22 @@
+#autoload
+
+local -a type typearg list
+
+zparseopts -D -E -a type t+:
+
+[[ -n $type[(r)fs] ]]   && typearg=( filesystem )
+[[ -n $type[(r)vol] ]]  && typearg=( $typearg volume )
+[[ -n $type[(r)snap] ]] && typearg=( $typearg snapshot )
+[[ -n $typearg ]] && typearg=( -t ${(j:,:)typearg} )
+
+datasetlist=( ${="$(zfs list -H -o name $typearg)":#no datasets available} )
+
+expl_type=${typearg[2,-1]//,/\/}
+if [[ -n $type[(r)mtpt] ]]; then
+	mlist=( ${="$(zfs list -H -o mountpoint $typearg)":#no mountpoints available} )
+	datasetlist=( $datasetlist $mlist )
+	expl_type="$expl_type/mountpoint"
+fi
+
+# compadd "$@" - $list
+_wanted dataset expl "$expl_type" _multi_parts "$@" / datasetlist
diff -urN Completion/Unix/Type/_zfs_pool Completion/Unix/Type/_zfs_pool
--- Completion/Unix/Type/_zfs_pool	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Type/_zfs_pool	2005-12-04 19:01:37.000000000 -0800
@@ -0,0 +1,3 @@
+#autoload
+
+compadd "$@" - $(zpool list -H -o name)
diff -urN Completion/Unix/Command/_zpool Completion/Unix/Command/_zpool
--- Completion/Unix/Command/_zpool	1969-12-31 16:00:00.000000000 -0800
+++ Completion/Unix/Command/_zpool	2007-09-15 22:51:24.000000000 -0700
@@ -0,0 +1,201 @@
+#compdef zpool
+
+_zpool() {
+	local -a subcmds fields
+
+	subcmds=(
+		  create destroy add remove list iostat status online
+		  offline clear attach detach replace scrub import export 
+		  upgrade history get set
+	)
+
+	fields=(
+		name\:"Pool name" size\:"Total size" used\:"Space used"
+		available\:"Space available" capacity\:"Space used (percentage)"
+		health\:"Health status"
+	)
+
+	properties=(
+		"bootfs:value:"
+		"autoreplace:value:(on off)"
+		"delegation:value:(on off)"
+	)
+	propnames=( ${properties%%:*} )
+
+	import_properties=(
+		xattr
+		copies
+		shareiscsi
+		canmount
+		share
+		sharenfs
+		userprop
+		mount
+	)
+
+	if [[ $service == "zpool" ]]; then
+		_arguments -C -A "-*" \
+			'-\?[Help]' \
+			'*::command:->subcmd' && return 0
+
+		if (( CURRENT == 1 )); then
+			_wanted commands expl "zpool subcommand" compadd -a subcmds
+			return
+		fi
+		service="$words[1]"
+		curcontext="${curcontext%:*}=$service:"
+	fi
+
+	case $service in
+	(clear)
+		_arguments \
+			':pool name:_zfs_pool' \
+			'*:virtual device:_files'
+		;;
+
+	(create)
+		# TODO: investigate better vdev handling
+		_arguments -A "-*" \
+			'-f[Force use of in-use devices]' \
+			'-n[Display configuration without creating pool]' \
+			'-R[Use alternate root]:alternate root:_files -/' \
+			'-m[Set mountpoint for root dataset]:mountpoint:' \
+			':pool name:' \
+			'*:virtual device:_files'
+		;;
+
+	(destroy)
+		_arguments -A "-*" \
+			'-f[Force active datasets to be unmounted]' \
+			':pool name:_zfs_pool'
+		;;
+
+	(add)
+		_arguments -A "-*" \
+			'-f[Force use of in-use devices]' \
+			'-n[Display configuration without modifying pool]' \
+			':pool name:_zfs_pool' \
+			'*:virtual device:_files'
+		;;
+
+	(list)
+		_arguments \
+			'-H[Scripted mode]' \
+			'-o[Fields to list]:field:_values -s , "field" ${^fields/\:/[}\]' \
+			'::pool name:_zfs_pool'
+		;;
+
+	(iostat)
+		_arguments -A "-*" \
+			'-v[Verbose statistics]' \
+			'*::pool name:_zfs_pool' \
+			'::interval:' \
+			'::count:'
+		;;
+
+	(status)
+		_arguments -A "-*" \
+			'-v[Verbose information]' \
+			'-x[Show only unhealthy pools]' \
+			'*::pool name:_zfs_pool'
+		;;
+
+	(offline)
+		_arguments -A "-*" \
+			'-t[Offline until next reboot]' \
+			':pool name:_zfs_pool' \
+			'*:virtual device:_files'
+		;;
+
+	(online)
+		_arguments \
+			':pool name:_zfs_pool' \
+			'*:virtual device:_files'
+		;;
+
+	(attach)
+		# TODO: first device should choose first from existing.
+		_arguments \
+			'-f[Force attach, even if in use]' \
+			':pool name:_zfs_pool' \
+			':virtual device:_files' \
+			':virtual device:_files'
+		;;
+
+	(detach)
+		_arguments \
+			':pool name:_zfs_pool' \
+			':virtual device:_files'
+		;;
+
+	(replace)
+		_arguments -A "-*" \
+			'-f[Force attach, even if in use]' \
+			':pool name:_zfs_pool' \
+			':virtual device:_files' \
+			'::virtual device:_files'
+		;;
+
+	(scrub)
+		_arguments -A "-*" \
+			'-s[Stop scrubbing]' \
+			'*:pool name:_zfs_pool'
+		;;
+
+	(export)
+		_arguments -A "-*" \
+			'-f[Forcefully unmount all datasets]' \
+			'*:pool name:_zfs_pool'
+		;;
+
+	(import)
+		# TODO: -o should complete options
+		_arguments -A "-*" \
+			'*-d[Search for devices or files in directory]:_files -/' \
+			'-D[Destroyed pools]' \
+			'-f[Force import]' \
+			- set1 \
+			'-o[Mount options]' \
+			'-p[Set property]:property:_values -s , "property" $import_properties' \
+			'-R[Alternate root]:_files -/' \
+			'*:pool name or id:_zfs_pool' \
+			'::new pool name:' \
+			- set2 \
+			'-a[All pools]'
+		;;
+
+	(get)
+		_arguments -A "-*" \
+			':property:_values -s , "property" $propnames all' \
+			'*:pool name:_zfs_pool'
+		;;
+
+	(set)
+		_arguments -A "-*" \
+			':property:_values -s , "property" $properties' \
+			'*:pool name:_zfs_pool'
+		;;
+
+	(upgrade)
+		_arguments -A "-*" \
+			- set1 \
+			'-v[Display ZFS versions and descriptions]' \
+			- set2 \
+			'-a[Upgrade all pools]' \
+			'*:pool name:_zfs_pool'
+		;;
+
+	(history)
+		_arguments -A "-*" \
+			'-i[Display internal events]' \
+			'-l[Long format]' \
+			'*:pool name:_zfs_pool'
+		;;
+
+	(*)
+		_message "unknown zpool subcommand: $service"
+		;;
+	esac
+}
+
+_zpool "$@"



Messages sorted by: Reverse Date, Date, Thread, Author