about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c17
-rw-r--r--Src/options.c1
-rw-r--r--Src/zsh.h1
3 files changed, 17 insertions, 2 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 8249deff2..5ad957f98 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4614,7 +4614,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
     char *name = shfunc->node.nam;
     int flags = shfunc->node.flags, ooflags;
     char *fname = dupstring(name);
-    int obreaks, saveemulation, restore_sticky;
+    int obreaks, ocontflag, oloops, saveemulation, restore_sticky;
     Eprog prog;
     struct funcstack fstack;
     static int oflags;
@@ -4626,7 +4626,9 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
     pushheap();
 
     oargv0 = NULL;
-    obreaks = breaks;;
+    obreaks = breaks;
+    ocontflag = contflag;
+    oloops = loops;
     if (trap_state == TRAP_STATE_PRIMED)
 	trap_return--;
     oldlastval = lastval;
@@ -4814,6 +4816,17 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
 	opts[XTRACE] = saveopts[XTRACE];
 	opts[PRINTEXITVALUE] = saveopts[PRINTEXITVALUE];
 	opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS];
+	opts[LOCALLOOPS] = saveopts[LOCALLOOPS];
+    }
+
+    if (opts[LOCALLOOPS]) {
+	if (contflag)
+	    zwarn("`continue' active at end of function scope");
+	if (breaks)
+	    zwarn("`break' active at end of function scope");
+	breaks = obreaks;
+	contflag = ocontflag;
+	loops = oloops;
     }
 
     endtrapscope();
diff --git a/Src/options.c b/Src/options.c
index 2163bff4d..6e4e7b911 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -180,6 +180,7 @@ static struct optname optns[] = {
 {{NULL, "listrowsfirst",      0},			 LISTROWSFIRST},
 {{NULL, "listtypes",	      OPT_ALL},			 LISTTYPES},
 {{NULL, "localoptions",	      OPT_EMULATE|OPT_KSH},	 LOCALOPTIONS},
+{{NULL, "localloops",	      OPT_EMULATE},		 LOCALLOOPS},
 {{NULL, "localpatterns",      OPT_EMULATE},		 LOCALPATTERNS},
 {{NULL, "localtraps",	      OPT_EMULATE|OPT_KSH},	 LOCALTRAPS},
 {{NULL, "login",	      OPT_SPECIAL},		 LOGINSHELL},
diff --git a/Src/zsh.h b/Src/zsh.h
index 05d582cda..fa7396112 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2129,6 +2129,7 @@ enum {
     LISTPACKED,
     LISTROWSFIRST,
     LISTTYPES,
+    LOCALLOOPS,
     LOCALOPTIONS,
     LOCALPATTERNS,
     LOCALTRAPS,