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

Oddball output from zerrmsg()



There's a discussion on the POSIX mailing list about "break"/"continue" RE
whether they should affect only loops "visible" to the statement (can be
thought of as "local" scope) or also those in calling scope.  Shells differ
on this point.

That is, currently, given:

    foo() { print FOO; break 2 }
    bar() { repeat 2 foo; print BAR }
    baz() { repeat 2 bar }

The zsh behavior is:

    % foo
    FOO
    foo:break: not in while, until, select, or repeat loop
    % bar
    FOO
    BAR
    % baz
    FOO
    % 

Note that "break 2" has interupted the loops in both bar and baz, even
though neither of them was in the scope of foo, and has thereby short-
circuited the "print" in bar.

With the proposed semantics:

    % baz
    FOO
    foo:break: not in while, until, select, or repeat loop
    % 

If we edit foo just a little:

    foo() { repeat 2; do print FOO; break 3; done }

Then (with the proposed "break" semantics):

    % baz
    FOO
    FOO
    BAR
    FOO
    FOO
    BAR
    % 

Thus "break 3" has interrupted only the innermost loop, the other two
in bar and baz are considered out of scope and proceed normally.

I don't have an opinion on which of these is preferable, this is all
just background material.

Now for the strange part.  I applied a small patch to doshfunc() to
implement the proposed behavior and ran "make check".  I got exactly
one failure, and it's a false positive:

============
./A07control.ztst: starting.
*** /tmp/zsh.ztst.err.64460     Tue Jun  3 18:57:24 2014
--- /tmp/zsh.ztst.terr.64460    Tue Jun  3 18:57:24 2014
***************
*** 1 ****
! fn:continue:1 not in while, until, select, or repeat loop
--- 1 ----
! fn:continue:1: not in while, until, select, or repeat loop
Test ./A07control.ztst failed: error output differs from expected as shown
above for:
  fn() {
    continue
  }
  fn
Was testing: continue outside loop
./A07control.ztst: test failed.
============

What?  Where did the colon after the line number in the error message go?
Why has it not been there all along?  I don't see the code path by which
that colon would ever have been omitted, yet A07control.ztst clearly was
not prepared for it to be there.  Any ideas?



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