zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: bad clash between process substitution and numeric glob
@ 2008-11-18  9:59 Peter Stephenson
  2008-11-18 15:24 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2008-11-18  9:59 UTC (permalink / raw)
  To: Zsh hackers list

% print <->(N)
zsh: command not found: N
<-/proc/self/fd/13

Luckily we need to know in advance where numeric globs are, so we can
handle them differently from redirections.  I've chosen to mark process
substitutions specially since it seemed the smaller change.

Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.47
diff -u -r1.47 lex.c
--- Src/lex.c	13 Nov 2008 21:18:14 -0000	1.47
+++ Src/lex.c	18 Nov 2008 09:53:19 -0000
@@ -33,7 +33,7 @@
 /* tokens */
 
 /**/
-mod_export char ztokens[] = "#$^*()$=|{}[]`<>?~`,'\"\\\\";
+mod_export char ztokens[] = "#$^*()$=|{}[]`<>>?~`,'\"\\\\";
 
 /* parts of the current token */
 
@@ -1160,7 +1160,7 @@
 		lexstop = 0;
 		goto brk;
 	    }
-	    add(Outang);
+	    add(OutangProc);
 	    if (skipcomm()) {
 		peek = LEXERR;
 		goto brk;
Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.76
diff -u -r1.76 parse.c
--- Src/parse.c	29 Sep 2008 08:46:33 -0000	1.76
+++ Src/parse.c	18 Nov 2008 09:53:20 -0000
@@ -1574,7 +1574,7 @@
 		 * we need process handling.
 		 */
 		if (p[1] == Inpar &&
-		    (*p == Equals || *p == Inang || *p == Outang)) {
+		    (*p == Equals || *p == Inang || *p == OutangProc)) {
 		    *complex = 1;
 		    break;
 		}
@@ -1833,7 +1833,7 @@
     }
     case REDIR_WRITE:
     case REDIR_WRITENOW:
-	if (tokstr[0] == Outang && tokstr[1] == Inpar)
+	if (tokstr[0] == OutangProc && tokstr[1] == Inpar)
 	    /* > >(...) */
 	    type = REDIR_OUTPIPE;
 	else if (tokstr[0] == Inang && tokstr[1] == Inpar)
@@ -1843,11 +1843,12 @@
 	if (tokstr[0] == Inang && tokstr[1] == Inpar)
 	    /* < <(...) */
 	    type = REDIR_INPIPE;
-	else if (tokstr[0] == Outang && tokstr[1] == Inpar)
+	else if (tokstr[0] == OutangProc && tokstr[1] == Inpar)
 	    YYERROR(ecused);
 	break;
     case REDIR_READWRITE:
-	if ((tokstr[0] == Inang || tokstr[0] == Outang) && tokstr[1] == Inpar)
+	if ((tokstr[0] == Inang || tokstr[0] == OutangProc) &&
+	    tokstr[1] == Inpar)
 	    type = tokstr[0] == Inang ? REDIR_INPIPE : REDIR_OUTPIPE;
 	break;
     }
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.92
diff -u -r1.92 subst.c
--- Src/subst.c	17 Nov 2008 16:11:30 -0000	1.92
+++ Src/subst.c	18 Nov 2008 09:53:20 -0000
@@ -152,12 +152,13 @@
     char *str  = str3, c;
 
     while (!errflag && (c = *str)) {
-	if (((c = *str) == Inang || c == Outang || (str == str3 && c == Equals))
+	if (((c = *str) == Inang || c == OutangProc ||
+	     (str == str3 && c == Equals))
 	    && str[1] == Inpar) {
 	    char *subst, *rest, *snew, *sptr;
 	    int str3len = str - str3, sublen, restlen;
 
-	    if (c == Inang || c == Outang)
+	    if (c == Inang || c == OutangProc)
 		subst = getproc(str, &rest);	/* <(...) or >(...) */
 	    else
 		subst = getoutputfile(str, &rest);	/* =(...) */
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.150
diff -u -r1.150 zsh.h
--- Src/zsh.h	30 Oct 2008 19:52:44 -0000	1.150
+++ Src/zsh.h	18 Nov 2008 09:53:20 -0000
@@ -147,28 +147,29 @@
 #define Tick		((char) 0x91)
 #define Inang		((char) 0x92)
 #define Outang		((char) 0x93)
-#define Quest		((char) 0x94)
-#define Tilde		((char) 0x95)
-#define Qtick		((char) 0x96)
-#define Comma		((char) 0x97)
+#define OutangProc	((char) 0x94)
+#define Quest		((char) 0x95)
+#define Tilde		((char) 0x96)
+#define Qtick		((char) 0x97)
+#define Comma		((char) 0x98)
 /*
  * Null arguments: placeholders for single and double quotes
  * and backslashes.
  */
-#define Snull		((char) 0x98)
-#define Dnull		((char) 0x99)
-#define Bnull		((char) 0x9a)
+#define Snull		((char) 0x99)
+#define Dnull		((char) 0x9a)
+#define Bnull		((char) 0x9b)
 /*
  * Backslash which will be returned to "\" instead of being stripped
  * when we turn the string into a printable format.
  */
-#define Bnullkeep       ((char) 0x9b)
+#define Bnullkeep       ((char) 0x9c)
 /*
  * Null argument that does not correspond to any character.
  * This should be last as it does not appear in ztokens and
  * is used to initialise the IMETA type in inittyptab().
  */
-#define Nularg		((char) 0x9c)
+#define Nularg		((char) 0x9d)
 
 /*
  * Take care to update the use of IMETA appropriately when adding
Index: Test/D02glob.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D02glob.ztst,v
retrieving revision 1.14
diff -u -r1.14 D02glob.ztst
--- Test/D02glob.ztst	30 Mar 2008 22:14:24 -0000	1.14
+++ Test/D02glob.ztst	18 Nov 2008 09:53:20 -0000
@@ -386,3 +386,9 @@
  [[ foo = (#c0)foo ]]
 1:Misplaced (#c...) flag
 ?(eval):1: bad pattern: (#c0)foo
+
+ mkdir glob.tmp/dir5
+ touch glob.tmp/dir5/N123
+ print glob.tmp/dir5/N<->(N)
+0:Numeric glob is not usurped by process substitution.
+>glob.tmp/dir5/N123


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: bad clash between process substitution and numeric glob
  2008-11-18  9:59 PATCH: bad clash between process substitution and numeric glob Peter Stephenson
@ 2008-11-18 15:24 ` Bart Schaefer
  2008-11-18 16:04   ` Peter Stephenson
  2008-11-18 17:46   ` Oliver Kiddle
  0 siblings, 2 replies; 5+ messages in thread
From: Bart Schaefer @ 2008-11-18 15:24 UTC (permalink / raw)
  To: Zsh hackers list

On Nov 18,  9:59am, Peter Stephenson wrote:
} Subject: PATCH: bad clash between process substitution and numeric glob
}
}  /**/
} -mod_export char ztokens[] = "#$^*()$=|{}[]`<>?~`,'\"\\\\";
} +mod_export char ztokens[] = "#$^*()$=|{}[]`<>>?~`,'\"\\\\";

Correct me if I'm wrong, but this is going to break zcompiled scripts
that were created with earlier versions of the shell.

Not that you need to avoid that, but it might be worth explicitly
calling out if true, and also bump the ZSH_VERSION number so it's
detectable at run time.

Or you could just put OutangProc at the end rather than renumbering
any of the existing tokens (I think).  Again I may be misguided.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: bad clash between process substitution and numeric glob
  2008-11-18 15:24 ` Bart Schaefer
@ 2008-11-18 16:04   ` Peter Stephenson
  2008-11-18 17:46   ` Oliver Kiddle
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2008-11-18 16:04 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer wrote:
> On Nov 18,  9:59am, Peter Stephenson wrote:
> } Subject: PATCH: bad clash between process substitution and numeric glob
> }
> }  /**/
> } -mod_export char ztokens[] = "#$^*()$=|{}[]`<>?~`,'\"\\\\";
> } +mod_export char ztokens[] = "#$^*()$=|{}[]`<>>?~`,'\"\\\\";
> 
> Correct me if I'm wrong, but this is going to break zcompiled scripts
> that were created with earlier versions of the shell.

I've no idea, that's all a complete black box to me.

> Not that you need to avoid that, but it might be worth explicitly
> calling out if true, and also bump the ZSH_VERSION number so it's
> detectable at run time.

That's easy to do anyway if that's going to be safer.

Index: Config/version.mk
===================================================================
RCS file: /cvsroot/zsh/zsh/Config/version.mk,v
retrieving revision 1.85
diff -u -r1.85 version.mk
--- Config/version.mk	3 Nov 2008 16:09:30 -0000	1.85
+++ Config/version.mk	18 Nov 2008 16:02:16 -0000
@@ -27,5 +27,5 @@
 # This must also serve as a shell script, so do not add spaces around the
 # `=' signs.
 
-VERSION=4.3.9-dev-0
-VERSION_DATE='November 3, 2008'
+VERSION=4.3.9-dev-1
+VERSION_DATE='November 18, 2008'


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: bad clash between process substitution and numeric glob
  2008-11-18 15:24 ` Bart Schaefer
  2008-11-18 16:04   ` Peter Stephenson
@ 2008-11-18 17:46   ` Oliver Kiddle
  2008-11-18 20:23     ` Peter Stephenson
  1 sibling, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2008-11-18 17:46 UTC (permalink / raw)
  To: Zsh hackers list

Bart wrote:
> Correct me if I'm wrong, but this is going to break zcompiled scripts
> that were created with earlier versions of the shell.
> 
> Not that you need to avoid that, but it might be worth explicitly
> calling out if true, and also bump the ZSH_VERSION number so it's
> detectable at run time.

My understanding was that the "magic" numbers in parse.c are supposed to
be changed if you break wordcode files. Seems the last person to change
those was me back in 2001. See Sven's comment to parse.c version 1.30
in CVS. I know I just followed what Sven had done so 03040506 became
04050607.

Oliver


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: bad clash between process substitution and numeric glob
  2008-11-18 17:46   ` Oliver Kiddle
@ 2008-11-18 20:23     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2008-11-18 20:23 UTC (permalink / raw)
  To: Zsh hackers list

On Tue, 18 Nov 2008 18:46:22 +0100
Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> Bart wrote:
> > Correct me if I'm wrong, but this is going to break zcompiled scripts
> > that were created with earlier versions of the shell.
> > 
> > Not that you need to avoid that, but it might be worth explicitly
> > calling out if true, and also bump the ZSH_VERSION number so it's
> > detectable at run time.
> 
> My understanding was that the "magic" numbers in parse.c are supposed to
> be changed if you break wordcode files. Seems the last person to change
> those was me back in 2001. See Sven's comment to parse.c version 1.30
> in CVS. I know I just followed what Sven had done so 03040506 became
> 04050607.

As there's a comparison after the magic numbers with the shell version,
I think that's only necessary if the header format changes (the first
FD_PRELEN words).  Otherwise changing the version number is good enough.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-18 20:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-18  9:59 PATCH: bad clash between process substitution and numeric glob Peter Stephenson
2008-11-18 15:24 ` Bart Schaefer
2008-11-18 16:04   ` Peter Stephenson
2008-11-18 17:46   ` Oliver Kiddle
2008-11-18 20:23     ` Peter Stephenson

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).