From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4434 invoked from network); 10 Sep 2009 14:44:37 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 10 Sep 2009 14:44:37 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 83878 invoked from network); 10 Sep 2009 14:44:24 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Sep 2009 14:44:24 -0000 Received: (qmail 2456 invoked by alias); 10 Sep 2009 14:44:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27260 Received: (qmail 2440 invoked from network); 10 Sep 2009 14:44:17 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 10 Sep 2009 14:44:17 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [208.87.233.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 63EEB8026E39 for ; Thu, 10 Sep 2009 16:44:05 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly14g.srv.mailcontrol.com (MailControl) with ESMTP id n8AEhkdu015826 for ; Thu, 10 Sep 2009 15:43:52 +0100 Received: from news01 ([10.99.50.25]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Sep 2009 15:40:53 +0100 Date: Thu, 10 Sep 2009 15:40:53 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: completion bug: treats substitution of unset parameter as empty string Message-ID: <20090910154053.3de0f8eb@news01> In-Reply-To: References: <19056.37899.24683.999959@gargle.gargle.HOWL> <200909100926.n8A9QFTh025636@news01.csr.com> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Sep 2009 14:40:53.0954 (UTC) FILETIME=[B3299A20:01CA3224] X-Scanned-By: MailControl A-09-22-01 (www.mailcontrol.com) on 10.71.0.124 X-Virus-Scanned: ClamAV 0.94.2/9791/Thu Sep 10 03:03:33 2009 on bifrost X-Virus-Status: Clean On Thu, 10 Sep 2009 10:30:42 -0400 Greg Klanderman wrote: > Here's a patch to fix the originally reported problem - that > _path_files incorrectly treats a parameter expansion of an > unset parameter as the empty string, i.e. that > > % ls $foobar/ > > lists completions under '/'. That's fine, however I think (belatedly answering your other question) that, since we don't need to backport this anywhere, using an anonymous function would be neater---so we're not relying on the value of "nounset" outside. In practice if it were set outside all hell would break loose, so this is pretty pernickety, but perhaps it's a useful precedent. Index: Completion/Unix/Type/_path_files =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v retrieving revision 1.47 diff -u -r1.47 _path_files --- Completion/Unix/Type/_path_files 5 Aug 2009 00:46:45 -0000 1.47 +++ Completion/Unix/Type/_path_files 10 Sep 2009 14:36:56 -0000 @@ -247,7 +247,11 @@ # meant as a partial path. linepath="${(M)pre##*\$[^/]##/}" - eval 'realpath=${(e)~linepath}' 2>/dev/null + function { + # do not treat an unset parameter expansion as the empty string + setopt localoptions nounset + eval 'realpath=${(e)~linepath}' 2>/dev/null + } [[ -z "$realpath" || "$realpath" = "$linepath" ]] && return 1 pre="${pre#${linepath}}" i='[^/]' -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom