From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22891 invoked by alias); 1 Apr 2015 12:25:46 -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: 20061 Received: (qmail 14998 invoked from network); 1 Apr 2015 12:25:45 -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, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f126d000001e9a-ab-551be0bbd2ef Date: Wed, 01 Apr 2015 13:15:25 +0100 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: device cannot be completed after "ip link show dev" Message-id: <20150401131525.69d06918@pwslap01u.europe.root.pri> In-reply-to: <20150401100718.GB2805@localhost.localdomain> References: <20150330033930.GB2856@localhost.localdomain> <20150331195701.4bc78e7c@ntlworld.com> <20150401100718.GB2805@localhost.localdomain> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKLMWRmVeSWpSXmKPExsVy+t/xa7q7H0iHGvxoM7DYcXIlowOjx6qD H5gCGKO4bFJSczLLUov07RK4Mn4/kCtYxluxfvU05gbGG1xdjJwcEgImEicuHmWDsMUkLtxb D2RzcQgJLGWUWDHjIjNIQkhgEZPE5nZ5iMQ2Rokn75+BdbAIqErcnH8brIhNwFBi6qbZjCC2 iICoxPIVm9lBbGEBB4l1P9+AxXkF7CVadv1nBbE5BawkriyewwIxdBKjxMnPP8GK+AX0Ja7+ /cQEcZK9xMwrZ6CaBSV+TL7HAmIzC2hJbN7WxAphy0tsXvMW6lJ1iRt3d7NPYBSahaRlFpKW WUhaFjAyr2IUTS1NLihOSs811CtOzC0uzUvXS87P3cQICdovOxgXH7M6xCjAwajEw8sZLRUq xJpYVlyZe4hRgoNZSYT38XXpUCHelMTKqtSi/Pii0pzU4kOMTBycUg2MhfMfsxaEvJyffb3G VDrd6Zyl49S66qk8CVmNoQ+zjlZ1iDL9ef5loprSsZvWSz//Sj4UcrWnYDuz3N3IhDY/tY7U q+e7/A56/6uxvr+6+WHOcz7Taycuq0489eWyXcvd/PyS3vf3dwsG8L6q4J482bnm6+KYpU5O /5ttp86pDYyZ+ubqVJsCJZbijERDLeai4kQAGJfc+jgCAAA= On Wed, 1 Apr 2015 18:07:19 +0800 Han Pingtian wrote: > What's going on when > > % ip link show dev > > , please? It looks like the old pattern > /$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ will match here, so the > action ':interfaces:network interface:_net_interfaces' will be bypassed? > But I think there is nothing at the position of , why the old > pattern would match a empty string? At that point it's not using the pattern, it's constructing a completion. It only uses the pattern to determine if a *previous* entry on the line is of a particular type. > > This is better. There's still a possible glitch: if a device springs > > into existence dynamically we won't accept it as a device already part > > of the command line argument, though we will still complete it as that > > calls _net_interfaces again. I think that's fairly minor. > > > I have tested (by set a fake net_intf_list) that if there is a interface > which named "dev", the completion will fail with this patch. I certain wouldn't expect to support a device called "dev" in the general case, that will screw up parsing horribly. > 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... that seems a reasonable optimisation since after a "dev" you don't care what the pattern is, it's automatically a device. Except I don't really understand what guards do, so this may need a bit more testing... pws