From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5738 invoked by alias); 1 Apr 2015 01:23:33 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20059 Received: (qmail 12271 invoked from network); 1 Apr 2015 01:23:31 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Wed, 1 Apr 2015 08:52:41 +0800 From: Han Pingtian To: zsh-users@zsh.org Subject: Re: device cannot be completed after "ip link show dev" Message-ID: <20150401005241.GA2805@localhost.localdomain> Mail-Followup-To: zsh-users@zsh.org References: <20150330033930.GB2856@localhost.localdomain> <5519F807.2030006@gmx.com> <150330215220.ZM28507@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <150330215220.ZM28507@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15040101-0033-0000-0000-00000044B8BF On Mon, Mar 30, 2015 at 09:52:20PM -0700, Bart Schaefer wrote: > diff --git a/Completion/Unix/Command/_ip b/Completion/Unix/Command/_ip > index 3b68c35..c0a28d3 100644 > --- a/Completion/Unix/Command/_ip > +++ b/Completion/Unix/Command/_ip > @@ -9,7 +9,8 @@ > # Values encoding simple types > # > local -a subcmd_dev > -subcmd_dev=(/$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ ':interfaces:network interface:_net_interfaces') > +subcmd_dev=(/$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ ':interfaces:network interface:_net_interfaces' "|" > + /$'dev\0'/ ':interfaces:network interface:_net_interfaces') > > local -a subcmd_onoff > subcmd_onoff=(/$'(on|off)\0'/ ':onoff:state (on or off):(on off)') > This works pretty good, besides "dev" will be completed after "dev". > > I suspect there should be some way to use the "-GUARD" syntax to prevent > "dev" from completing again after "dev" ("ip link show dev dev" doesn't > make sense, does it?) but there's no example of using a guard, and as > someone implied, offering too much (as long as it's not *TOO* much) is > better than offering too little. I found that we can use "-'false'" as the the guard here: subcmd_dev=(/$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ -'false' ':interfaces:network interface:_net_interfaces') then only network device will be completed after dev: % ip link show dev network interface em1 lo tun0 wlp3s0 or even using "[]" as the pattern has the same effect: subcmd_dev=(/$'[]'/ ':interfaces:network interface:_net_interfaces') But both of them will report parsing error when trying to complete after the interface: % ip link show dev lo parse failed before current word