Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: break: more completely enumerate loop types we are not in
- X-seq: zsh-workers 55055
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: PATCH: break: more completely enumerate loop types we are not in
- Date: Sat, 1 Aug 2026 06:38:53 +0200
- Archived-at: <https://zsh.org/workers/55055>
- In-reply-to: <CAH+w=7aqY8wsSSczg_79gPzeA2zfQA=hLhKhXXnLLgNKK_0GKQ@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAH+w=7aqY8wsSSczg_79gPzeA2zfQA=hLhKhXXnLLgNKK_0GKQ@mail.gmail.com>
---
I've had this patch lying around but never sent it (obviously).
Src/builtin.c | 4 ++--
Test/A07control.ztst | 9 ++++++++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Src/builtin.c b/Src/builtin.c
index 9d9460a6a4..cc7e3375bb 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -5821,13 +5821,13 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func)
switch (func) {
case BIN_CONTINUE:
if (!loops) { /* continue is only permitted in loops */
- zerrnam(name, "not in while, until, select, or repeat loop");
+ zerrnam(name, "not in for, while, until, select, or repeat loop");
return 1;
}
contflag = 1; /* FALLTHROUGH */
case BIN_BREAK:
if (!loops) { /* break is only permitted in loops */
- zerrnam(name, "not in while, until, select, or repeat loop");
+ zerrnam(name, "not in for, while, until, select, or repeat loop");
return 1;
}
breaks = nump ? minimum(num,loops) : 1;
diff --git a/Test/A07control.ztst b/Test/A07control.ztst
index b1a2487324..a3a82a68d1 100644
--- a/Test/A07control.ztst
+++ b/Test/A07control.ztst
@@ -23,12 +23,19 @@
>start 255
>255
+ $ZTST_testdir/../Src/zsh -fc 'fn() {
+ break
+ }
+ fn'
+1:break outside loop
+?fn:break:1: not in for, while, until, select, or repeat loop
+
$ZTST_testdir/../Src/zsh -fc 'fn() {
continue
}
fn'
1:continue outside loop
-?fn:continue:1: not in while, until, select, or repeat loop
+?fn:continue:1: not in for, while, until, select, or repeat loop
for outer in 0 1 2 3; do
print outer $outer
--
2.38.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author