Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Zsh 3.1.6 - ${~foo} expansion bug



Bart Schaefer wrote:

> On Feb 8, 12:16am, Alexandre Duret-Lutz wrote:
> > Subject: Re: Zsh 3.1.6 - ${~foo} expansion bug
> >
> > From my experiments I am tempted to deduce that this is
> > reproducible as long as you don't call a builtin before
> > the for loop.
> 
> This is exactly correct; I recompiled with --disable-zshenv to be
> absolutely certain that no commands were executed by "zsh -f",
> and now I can reproduce the problem as well.
> 
> Tracing through, I find that after a builtin has been executed,
> the `esglob' == 1 at exec.c:1516.  The first time through the "for"
> loop, when it misbehaves, `esglob' == 0.  And sure enough, esglob
> is a static which is not initialized until execcmd() is called.
> 
> I imagine there some similar problem with `esprefork'.  I don't
> know where these should be getting initialized, though, nor what
> the right starting value for `esprefork' should be, though `esglob'
> clearly ought to be initialized to 1.

The initialisation to `1' for esglob in the patch below shouldn't
really be necessary, because both es* should be set up when one of the 
functions calling execsubst() will be called.

What really confused me is that the test was still in the order in
which it was. I *know* I once changed that -- obviously I didn't send
a patch for it.

Sorry!

Bye
 Sven

diff -ru ../z.old/Src/exec.c Src/exec.c
--- ../z.old/Src/exec.c	Tue Feb  8 10:16:04 2000
+++ Src/exec.c	Tue Feb  8 10:22:15 2000
@@ -1506,7 +1506,7 @@
     }
 }
 
-static int esprefork, esglob;
+static int esprefork, esglob = 1;
 
 /**/
 void
@@ -1917,10 +1917,10 @@
 	is_exec = 1;
     }
 
-    if (args && (esglob = !(cflags & BINF_NOGLOB))) {
+    if ((esglob = !(cflags & BINF_NOGLOB)) && args) {
 	LinkList oargs = args;
 	globlist(args);
-	args=oargs;
+	args = oargs;
     }
     if (errflag) {
 	lastval = 1;

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author