From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh Hackers' List <zsh-workers@sunsite.dk>
Subject: Re: zsh handling of non-standard if-evaluations
Date: Fri, 2 Feb 2007 21:32:35 +0000 [thread overview]
Message-ID: <20070202213235.4027f588.p.w.stephenson@ntlworld.com> (raw)
In-Reply-To: <200701282157.l0SLveDn003073@pwslaptop.csr.com>
On Sun, 28 Jan 2007 21:57:40 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> 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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
parent reply other threads:[~2007-02-02 21:32 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <200701282157.l0SLveDn003073@pwslaptop.csr.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070202213235.4027f588.p.w.stephenson@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).