From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23468 invoked from network); 2 Feb 2007 21:32:18 -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.5 required=5.0 tests=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; 2 Feb 2007 21:32:18 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 94715 invoked from network); 2 Feb 2007 21:32:10 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 2 Feb 2007 21:32:10 -0000 Received: (qmail 27142 invoked by alias); 2 Feb 2007 21:32:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23143 Received: (qmail 27115 invoked from network); 2 Feb 2007 21:32:00 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 2 Feb 2007 21:32:00 -0000 Received: (qmail 93567 invoked from network); 2 Feb 2007 21:32:00 -0000 Received: from mtaout02-winn.ispmail.ntl.com (81.103.221.48) by a.mx.sunsite.dk with SMTP; 2 Feb 2007 21:31:53 -0000 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20070202213152.ZEPK3103.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Fri, 2 Feb 2007 21:31:52 +0000 Received: from pwslaptop.csr.com ([81.107.45.94]) by aamtaout01-winn.ispmail.ntl.com with SMTP id <20070202213152.HPZP219.aamtaout01-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Fri, 2 Feb 2007 21:31:52 +0000 Date: Fri, 2 Feb 2007 21:32:35 +0000 From: Peter Stephenson To: Zsh Hackers' List Subject: Re: zsh handling of non-standard if-evaluations Message-Id: <20070202213235.4027f588.p.w.stephenson@ntlworld.com> In-Reply-To: <200701282157.l0SLveDn003073@pwslaptop.csr.com> References: <184104.7951.qm@web36811.mail.mud.yahoo.com> <200701282157.l0SLveDn003073@pwslaptop.csr.com> X-Mailer: Sylpheed version 2.2.10 (GTK+ 2.10.4; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 28 Jan 2007 21:57:40 +0000 Peter Stephenson wrote: > (That seems a little strange, actually. Either you'd expect == to find > a programme called =, or you'd expect == to be a normal argument without > any pattern match failure. It seems that you need to quote the second > argument: =\= does find = in the path. That strikes me as a bug.) Here's a rationalization, so that == does find = (unless NO_EQUALS is on, obviously), and likewise for any other metacharacters that haven't been dealt with at the time of the = expansion (note this is before globbing---necessarily in the case of ~-expansion which is performed at the same time as =-expansion). However, it's very tempting to make "==" an exception (and document it) since it's kind of intuitively obvious (if you're a geek) that "==" is a test for equality rather than an attempt to look for a programme called "=". Still, POSIX doesn't give any imperative reason to do so. (In case anyone's unclear, == in [[ ... ]] is and has always been handled specially because zsh understands the syntax of [[ ... ]], so it doesn't get handled as a normal command. [ ... ] and test, on the other hand, are ordinary builtins, hence the problem.) Index: Src/string.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/string.c,v retrieving revision 1.8 diff -u -r1.8 string.c --- Src/string.c 28 Oct 2005 17:34:33 -0000 1.8 +++ Src/string.c 2 Feb 2007 21:29:26 -0000 @@ -135,7 +135,7 @@ return ptr; } -/* like strdup(), but with a specified length */ +/* like dupstring(), but with a specified length */ /**/ mod_export char * Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.73 diff -u -r1.73 subst.c --- Src/subst.c 26 Jan 2007 19:18:17 -0000 1.73 +++ Src/subst.c 2 Feb 2007 21:29:27 -0000 @@ -570,21 +570,21 @@ return 1; } } else if (*str == Equals && isset(EQUALS) && str[1]) { /* =foo */ - char sav, *pp, *cnam; + char *pp, *cnam, *cmdstr, *str1 = str+1; - for (pp = str + 1; !isend2(*pp); pp++); - sav = *pp; - *pp = 0; - if (!(cnam = findcmd(str + 1, 1))) { + for (pp = str1; !isend2(*pp); pp++) + ; + cmdstr = dupstrpfx(str1, pp-str1); + untokenize(cmdstr); + remnulargs(cmdstr); + if (!(cnam = findcmd(cmdstr, 1))) { if (isset(NOMATCH)) - zerr("%s not found", str + 1); + zerr("%s not found", cmdstr); return 0; } *namptr = dupstring(cnam); - if (sav) { - *pp = sav; + if (*pp) *namptr = dyncat(*namptr, pp); - } return 1; } return 0; -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/