From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: Zsh workers <zsh-workers@zsh.org>
Subject: Re: PATCH: update completions for some common Unix commands
Date: Thu, 7 May 2015 00:40:59 +0000 [thread overview]
Message-ID: <20150507004059.GA1983@tarsus.local2> (raw)
In-Reply-To: <4262.1430949497@quattro>
Oliver Kiddle wrote on Wed, May 06, 2015 at 23:58:17 +0200:
> Daniel Shahaf wrote:
> > Should jail names be offered as completions, rather than just as
> > descriptions? I think most jail-related commands commands accept either
> > jname or jid to identify a jail.
>
> ps and pgrep both seem to require IDs but allow 0 for processes that are
> not part of a jail. Do jail-related commands accepting names have a name
> for the host system?
None do that I know of. Neither the fully-qualified hostname nor the
base hostname works (tested with either ps and jexec).
> There's probably commands somewhere that can take either jids or names
> (jls being one example) but that's not yet handled.
How about handling those by completing just the jnames and not the jids?
After all, jnames are stable (across jail stop/start cycles) but jids
aren't.
When "0" is accepted, we could complete it in addition to running jails'
names. So for example, 'ps -J' would complete 0 plus running jnames,
and jexec would complete just jnames:
diff --git a/Completion/BSD/Command/_jexec b/Completion/BSD/Command/_jexec
new file mode 100644
index 0000000..99dcb00
--- /dev/null
+++ b/Completion/BSD/Command/_jexec
@@ -0,0 +1,7 @@
+#compdef jexec
+
+_arguments -s -S : \
+ '-u[host username]:host username the command will run as:_users' \
+ '-U[jail username]:jail username the command will run as' \
+ '(-)1:jail to execute the command in:_jails -o name' \
+ '*:::arguments: _normal'
> +local addhost host param desc=1
> +local -a args expl
> +zparseopts -D -K -E 0=addhost o:=param
> +param=${param[2]:-jid}
> +
> +jails=( ${${(f)"$(_call_program jails jls $param name)"}/ /:} )
Missing 'local -a jails'.
Thanks,
Daniel
P.S. Until FreeBSD 10.1 or so, rc.d/jail would set the jname equal to
the jid, so the distinction between jname/jid completion is harder to
see in those systems.
next prev parent reply other threads:[~2015-05-07 0:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 9:58 Oliver Kiddle
2015-05-05 21:54 ` Daniel Shahaf
2015-05-06 21:58 ` Oliver Kiddle
2015-05-07 0:40 ` Daniel Shahaf [this message]
2015-05-11 5:32 ` Eric Cook
2015-05-11 11:07 ` Oliver Kiddle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150507004059.GA1983@tarsus.local2 \
--to=d.s@daniel.shahaf.name \
--cc=okiddle@yahoo.co.uk \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).