1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-06 09:01:13 +02:00

44271: Fix breaks propagated from until or return.

If the until or return test caused continuation but there was
a pending return, breaks didn't get cancelled causing enclosing
scope to skip commands.
This commit is contained in:
Peter Stephenson 2019-05-03 20:34:53 +01:00
parent 8ce9e20c49
commit 588bb77cb6
3 changed files with 22 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2019-05-03 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 44271: Src/loop.c, Test/A01grammar.ztst: until with positive
and while with negative status propagated breaks too far after a
return, causing code in enclosing scope not to run.
2019-04-26 dana <dana@dana.is> 2019-04-26 dana <dana@dana.is>
* 44234: Completion/Unix/Command/_ssh: Update for OpenSSH 8.0 * 44234: Completion/Unix/Command/_ssh: Update for OpenSSH 8.0

View file

@ -425,7 +425,7 @@ execwhile(Estate state, UNUSED(int do_exec))
breaks--; breaks--;
simple_pline = old_simple_pline; simple_pline = old_simple_pline;
} else } else {
for (;;) { for (;;) {
state->pc = loop; state->pc = loop;
noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN; noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN;
@ -445,8 +445,11 @@ execwhile(Estate state, UNUSED(int do_exec))
lastval = oldval; lastval = oldval;
break; break;
} }
if (retflag) if (retflag) {
if (breaks)
breaks--;
break; break;
}
/* In case the loop body is also a functional no-op, /* In case the loop body is also a functional no-op,
* make sure signal handlers recognize ^C as above. */ * make sure signal handlers recognize ^C as above. */
@ -470,6 +473,7 @@ execwhile(Estate state, UNUSED(int do_exec))
freeheap(); freeheap();
oldval = lastval; oldval = lastval;
} }
}
cmdpop(); cmdpop();
popheap(); popheap();
loops--; loops--;

View file

@ -640,6 +640,16 @@
>1 >1
>0 >0
echo 'echo dot
until return 42; do
:
done' >until_dot
. ./until_dot
echo After dot
0:return in positive until test in dot file does not cause excess breaks
>dot
>After dot
echo 'echo $?' >dot_status echo 'echo $?' >dot_status
false false
. ./dot_status . ./dot_status