From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4909 invoked by alias); 7 May 2015 00:53:16 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35051 Received: (qmail 1800 invoked from network); 7 May 2015 00:53:16 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=pRqpaEjx84/+7D1iO43QOCWyvHk=; b=LzC9zI D76P5WI+1VX7YVab8g3ElBGw1pXTy8eSv9kNywzXx+wZRMsITLAANxFwPiYRwgUu BLnR2PFzsh+YOL+3UwnFzOX25y/ELqwvadFY97GQR5clh3/P4/wdqmfvwauoAjUc Cp9N7WUp6amFmImJUM5tnqtz7+myb8pciySUs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=pRqpaEjx84/+7D1iO43QOCWyvHk=; b=sOGnd yppJqdAwBWW6xfn/IvL2L1dZrHIwX09PGmndVUaljbTMRoqlZvZnFwY91uG7uCFh Eze7mos3EQXfUuEliBjflTPEIOaGYNOJhBAHYbucNQT7mjjt6iNbn50YAohU9aLu 02azezsjcLyYHfGOZ4JXXjdiBhVTsXW7iUCpqk= X-Sasl-enc: x2JmbeYiE0pVCVpQr9P+NgZAqonH8IUg1LEmZLn+PDky 1430959267 Date: Thu, 7 May 2015 00:40:59 +0000 From: Daniel Shahaf To: Oliver Kiddle Cc: Zsh workers Subject: Re: PATCH: update completions for some common Unix commands Message-ID: <20150507004059.GA1983@tarsus.local2> References: <10432.1430474309@quattro> <20150505215445.GC2020@tarsus.local2> <4262.1430949497@quattro> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4262.1430949497@quattro> User-Agent: Mutt/1.5.21 (2010-09-15) 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.