From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26250 invoked by alias); 2 Apr 2015 08:13:35 -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: 20065 Received: (qmail 16401 invoked from network); 2 Apr 2015 08:13: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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.2 Date: Thu, 2 Apr 2015 16:03:07 +0800 From: Han Pingtian To: zsh-users@zsh.org Subject: Re: device cannot be completed after "ip link show dev" Message-ID: <20150402080307.GD2805@localhost.localdomain> Mail-Followup-To: zsh-users@zsh.org References: <20150330033930.GB2856@localhost.localdomain> <20150331195701.4bc78e7c@ntlworld.com> <20150401100718.GB2805@localhost.localdomain> <20150401131525.69d06918@pwslap01u.europe.root.pri> <150401084744.ZM30889@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <150401084744.ZM30889@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: 15040208-0033-0000-0000-0000041DD793 On Wed, Apr 01, 2015 at 08:47:44AM -0700, Bart Schaefer wrote: > On Apr 1, 1:15pm, Peter Stephenson wrote: > } > } > And I have figured out this works: > } > > } > subcmd_dev=( > } > /$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ > } > -'if [[ $words[CURRENT-1] = dev ]];then false;else true;fi' > } > ':interfaces:network interface:_net_interfaces' > } > ) > } > } I didn't even know what format guards could take in general... > > They're just passed to "eval" and the exit status checked. If false, > the pattern is presumed not to match. The pattern is evaluated with > backreferences enabled, so normally you'd refer to $match in the guard, > but in this case maybe we want to examine previous words rather than > the one to which the pattern is being applied. > > subcmd_dev=( > /$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ > -'[[ $words[CURRENT-1] != dev ]]' > ':interfaces:network interface:_net_interfaces' > ) > > should be equivalent, but I suspect we might really want to examine the > whole array slice $words[2,CURRENT-1] to see if "dev" appears anywhere. If using -'[[ $words[2,CURRENT-1] != *dev* ]]', then "dev" and "up" won't be completed after dev (this is right, dev after dev is wrong syntax), but there is a prase failed warning : % ip link show dev em1 parse failed before current word