about summary refs log tree commit diff
path: root/Test/C03traps.ztst
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-03-10 10:50:00 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-03-10 10:50:00 +0000
commit1316a6b44123df11b98811ef243154a6e54b9bcc (patch)
tree8322c39367e58e32d18e1e662173f2fef335211b /Test/C03traps.ztst
parent3f7b447d88056cbbe524391d843591e28bef3384 (diff)
downloadzsh-1316a6b44123df11b98811ef243154a6e54b9bcc.tar.gz
zsh-1316a6b44123df11b98811ef243154a6e54b9bcc.tar.xz
zsh-1316a6b44123df11b98811ef243154a6e54b9bcc.zip
19575: Fix problem with trap on EXIT overriding status
Diffstat (limited to 'Test/C03traps.ztst')
-rw-r--r--Test/C03traps.ztst16
1 files changed, 16 insertions, 0 deletions
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 81ef38a30..26ba73da5 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -196,3 +196,19 @@
   f
   functions TRAPWINCH
 1:Unsetting ordinary traps with localtraps.
+
+#
+# Returns from within traps are a perennial problem.
+# The following two apply to returns in and around standard
+# ksh-style traps.  The intention is that a return value from
+# within the function is preserved (i.e. statuses set by the trap
+# are ignored) unless the trap explicitly executes `return', which makes
+# it return from the enclosing function.
+#
+  fn() { trap 'true' EXIT; return 1; }
+  fn
+1: ksh-style EXIT traps preserve return value
+
+  inner() { trap 'return 3' EXIT; return 2: }
+  outer() { inner; return 1; }
+3: ksh-style EXIT traps can force return status of enclosing function