Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: completion for FreeBSD jail command
- X-seq: zsh-workers 42571
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: completion for FreeBSD jail command
- Date: Sat, 31 Mar 2018 00:02:07 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1522482639; bh=bJWtY3rnJ/psZQB0yRhfLkCouTclbAv7aqJerCqv9Bo=; h=From:To:Subject:Date:From:Subject; b=DoRoEGf8kckR5B43kBst7y8wZ8OcXbFeCB2HwhiYq+FBAikoSceLRPJj+XfNI1+xtlP3rWD11EcwvuiOgMASVVOdgV4x93oJfjTnYdXLUK/j6ii7lEWMtMBl8BMeShWAd+/uNRgQUJ2unoGuZuanHqsQKnISw4dABGPCLof1fwwQ5GozOy/lc/ciZIZSTbzvKZQGDcAeK9rAGve3C1Q/OuM0eASzOEHUK4tMN2T/sfOCLwTVI+f1k56TFha8HqOha76V2nz7oOMz2ET+QjU4I+CWXFMkU9T+DHaR+xwYP8tPnu4rC/x/PnUS60R318UcI2WS8cdT4f5bQnd79/BUMw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
This adds completion for the FreeBSD jail command. This is the low-level
plumbing command so may not be widely used directly but I use it.
I've not made any attempt to handle Dragonfly based on online manpages
because differences appear to be more than just a few options.
There's also a tweak to _jexec to use _call_program.
Oliver
diff --git a/Completion/BSD/Command/_jail b/Completion/BSD/Command/_jail
new file mode 100644
index 000000000..26d0a6a87
--- /dev/null
+++ b/Completion/BSD/Command/_jail
@@ -0,0 +1,53 @@
+#compdef jail
+
+local curcontext="$curcontext" ret=1
+local -a state state_descr line jails running alts suf
+local -A opt_args
+
+_arguments -C -s \
+ '-c[create a new jail]' \
+ '-m[modify an existing jail]' \
+ '-r[remove specified jail]' \
+ '-d[allow changes to a dying jail]' \
+ '-f+[specify configuration file]:config file [/etc/jail.conf]:_files' \
+ '-h[resolve host.hostname and use IP addresses for the jail]' \
+ '(-q)-i[output jail ID of new jails]' \
+ '-J+[write a file containing parameters used to start the jail]:file:_files' \
+ '-p+[limit the number of commands from exec.* that can run simultaneously]:limit' \
+ '(-i -v)-q[suppress the message printed when a jail is created, modified or removed]' \
+ '-R[remove jail without using the configuration file]' \
+ '(-q)-v[print a message on every operation]' \
+ '!-n+:name' '!-l' '!-s+:secure level' \!-{u,U}'+:user:_users' \
+ '*:: :->args' && ret=0
+
+if [[ -n $state ]]; then
+ if compset -P 1 '(^name)='; then
+ case ${IPREFIX%=} in
+ command|exec.*st(art|op)*) _cmdstring && ret=0 ;;
+ depend) _jails && ret=0 ;;
+ path) _directories && ret=0 ;;
+ host|vnet) alts=( 'values:value:(inherit new)' ) ;;
+ ip[46]) alts=( 'values:value:(inherit new disable)' ) ;;
+ *_user) _users && ret=0 ;;
+ *) _message -e values 'value' ;;
+ esac
+ elif compset -P name= || [[ $#line = 1 ]]; then
+ if (( $+opt_args[-r] || $+opt_args[-m] )); then
+ alts=( 'jails:jail:_jails' )
+ elif (( $+opt_args[-c] )); then
+ running=( ${${(f)"$(_call_program jails jls name)"}/ /:} )
+ jails=( ${${(M)${(f)"$(<${opt_args[-f]:-/etc/jail.conf})"}:#[a-z]# #\{#(#e)}%% *} )
+ alts=( "jails:jail:compadd - ${jails:|running}" )
+ fi
+ fi
+ if [[ -z $IPREFIX ]]; then
+ compset -S '=*' || suf=( -qS = )
+ alts+=(
+ 'parameters:parameter:compadd -r "\n\t\- =" - persist allow.{set_hostname,sysvipc,raw_sockets,chflags,mount{,.devfs,.fdescfs,.nullfs,.procfs,.linprocfs,.linsysfs,.tmpfs,.zfs},quotas,socket_af} mount.{devfs,fdescfs,procfs}'
+ 'parameters:parameter:compadd $suf - jid name path ip{4,6}{,.addr{,sel}} vnet host.hostname host securelevel devfs_ruleset children.{max,cur} enforce_statfs cpuset.id osrelease osreldate command exec.{{,pre,post}{start,stop},clean,jail_user,system{,_jail}_user,timeout,consolelog,fib} stop.timeout {vnet.,}interface ip_hostname mount{,.fstab} depend'
+ )
+ fi
+ (( $#alts )) && _alternative $alts && ret=0
+fi
+
+return ret
diff --git a/Completion/BSD/Command/_jexec b/Completion/BSD/Command/_jexec
index 85829d10e..6a2d05a81 100644
--- a/Completion/BSD/Command/_jexec
+++ b/Completion/BSD/Command/_jexec
@@ -4,7 +4,7 @@ _jexec_normal() {
local PATH=$PATH
local -a _comp_priv_prefix
# relative paths are relative to the jail's root
- path=( "$(command jls -j $words[1] path)"/$^path )
+ path=( "$(_call_program paths jls -j $words[1] path)"/$^path )
shift 1 words; (( CURRENT-- ))
_normal
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author