From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3263 invoked from network); 10 Nov 2006 09:57:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Nov 2006 09:57:25 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 47933 invoked from network); 10 Nov 2006 09:57:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Nov 2006 09:57:20 -0000 Received: (qmail 25239 invoked by alias); 10 Nov 2006 09:57:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22993 Received: (qmail 25230 invoked from network); 10 Nov 2006 09:57:17 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Nov 2006 09:57:17 -0000 Received: (qmail 47608 invoked from network); 10 Nov 2006 09:57:17 -0000 Received: from cluster-c.mailcontrol.com (168.143.177.190) by a.mx.sunsite.dk with SMTP; 10 Nov 2006 09:57:13 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly23c.srv.mailcontrol.com (MailControl) with ESMTP id kAA9uhc7014289 for ; Fri, 10 Nov 2006 09:57:01 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Fri, 10 Nov 2006 09:56:42 +0000 Date: Fri, 10 Nov 2006 09:56:41 +0000 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: bug : _make and special parameters Message-Id: <20061110095641.7f1fdebd.pws@csr.com> In-Reply-To: <200611091050.kA9AoPSq022667@news01.csr.com> References: <20061108194249.GA8389@localhost.localdomain> <200611091050.kA9AoPSq022667@news01.csr.com> Organization: Cambridge Silicon Radio X-Mailer: Sylpheed version 2.2.9 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Nov 2006 09:56:42.0948 (UTC) FILETIME=[866D5040:01C704AE] X-Scanned-By: MailControl A-07-06-70 (www.mailcontrol.com) on 10.67.0.133 Peter Stephenson wrote: > parseMakefile can > run recursively, because it handles include declarations, so the > variables need to go in the top-level namespace. There's no easy way of > ensuring this, unfortunately, since there's no way of making the > parameter local (necessary since the global parameter is special) but at > a particular level. So I'll commit your patch for now. Here's another version: only variables that match existing specials are declared as local and hidden. I wrote this just to hedge my bets, leaving everything working for most variables but fixing arno's problem if they happen to match specials, but it's actually slightly better: the first "local" will hide the special and the ${(tP)$var} won't show up a special any more, so the hiding variable won't subsequently be relocalised. However, you still lose the scope if the variable was first mentioned in an included makefile, so it's not a complete fix. You could do that with two scans, but it doesn't seem worth it. Index: Completion/Unix/Command/_make =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_make,v retrieving revision 1.18 diff -u -r1.18 _make --- Completion/Unix/Command/_make 9 Nov 2006 10:52:46 -0000 1.18 +++ Completion/Unix/Command/_make 10 Nov 2006 09:56:03 -0000 @@ -51,6 +51,12 @@ done } +# parseMakefile only runs inside $(...), so it doesn't matter that +# it pollutes the global namespace, setting zsh variables to +# make variables. The difficult case is where a make variable +# is special in zsh; we use local -h to hide those. This +# isn't a complete solution since it means variables defined in +# included Makefiles are undefined before returning to the parent. parseMakefile() { local input var val TAB=$'\t' dir=$1 @@ -60,7 +66,7 @@ var=${input%%[ $TAB]#=*} val=${input#*=} val=${val##[ $TAB]#} - local -h $var + [[ ${(tP)var} = *special ]] && local -h $var eval $var=\$val ;; ([[:alnum:]][[:alnum:]_]#[ $TAB]#:=*) @@ -68,7 +74,7 @@ val=${input#*=} val=${val##[ $TAB]#} val=$(expandVars 10 $val) - local -h $var + [[ ${(tP)var} = *special ]] && local -h $var eval $var=\$val ;; ([[:alnum:]][^$TAB:=]#:[^=]*) -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php