summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Src/loop.c14
-rw-r--r--Test/A01grammar.ztst8
3 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index b4bb526d7..d015c5da6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-05-11  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
+	* users/12848: Test/A01grammar.ztst, Src/loops.c: return, break
+	and continue are allowed in "always" block and will override
+	try block if set.
+
 	* 24994: Src/Zle/zle_hist.c: Fix problem with
 	up/down-line-or-search comparison, perhaps.
 
diff --git a/Src/loop.c b/Src/loop.c
index 9e19f3f93..3a6296d45 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -631,7 +631,7 @@ exectry(Estate state, int do_exec)
 {
     Wordcode end, always;
     int endval;
-    int save_retflag, save_breaks, save_loops, save_contflag;
+    int save_retflag, save_breaks, save_contflag;
     zlong save_try_errflag, save_try_tryflag;
 
     end = state->pc + WC_TRY_SKIP(state->pc[-1]);
@@ -664,8 +664,6 @@ exectry(Estate state, int do_exec)
     retflag = 0;
     save_breaks = breaks;
     breaks = 0;
-    save_loops = loops;
-    loops = 0;
     save_contflag = contflag;
     contflag = 0;
 
@@ -674,10 +672,12 @@ exectry(Estate state, int do_exec)
 
     errflag = try_errflag ? 1 : 0;
     try_errflag = save_try_errflag;
-    retflag = save_retflag;
-    breaks = save_breaks;
-    loops = save_loops;
-    contflag = save_contflag;
+    if (!retflag)
+	retflag = save_retflag;
+    if (!breaks)
+	breaks = save_breaks;
+    if (!contflag)
+	contflag = save_contflag;
 
     cmdpop();
     popheap();
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 93a1ecb8c..f283451ce 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -332,6 +332,14 @@
 >Status after always block is 1.
 ?(eval):3: bad substitution
 
+  fn() { { return } always { echo always 1 }; echo not executed }
+  fn
+  fn() { { echo try 2 } always { return }; echo not executed }
+  fn
+0:Always block interaction with return
+>always 1
+>try 2
+
 # Outputting of structures from the wordcode is distinctly non-trivial,
 # we probably ought to have more like the following...
   fn1() { { echo foo; } }