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

Re: For loop bug



Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx> writes:

> Philippe Troin wrote:
> > Tried on zsh 4.0.4 and 4.0.6:
> > 
> >   % for i in 1 2 3; do echo $i || break; done && echo X
> >   1
> >   X
> >   2
> >   X
> >   3
> >   X
> >   X
> >   % 
> > 
> > That looks somewhat incorrect...
> 
> Oh, *yuk*.
> 
> > Or did I miss something?
> 
> Non, hélas.
> 
> The wordcode is pretty horrific to debug: it's uncommented and as an
> unstructured array of integers completely opaque to all debugging tools.
> Tentative patch below --- passes all tests, including the new one (which
> Philippe will recognise).  It's actually against 4.1, but I doubt if
> much has changed here.
> 
> I may leave this till Monday for people to scratch their heads over.

Does it fix this one as well?

  % for i in 1 2 3; do { {echo $i; [[ $i == 2 ]] && exit 1; } || break }; \
  > done && echo X
  1
  X
  % 

I would have expected:

  1
  2
  X 

or 

  1
  2

But surely not 1 X.

Phil.



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