From 05b06b1c08263af07b2297aac0c842dafca39445 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 6 Feb 2005 20:36:09 +0000 Subject: fix autoloaded trap bug; rejig use of trapfuncs (now traplists); improve trap tests --- Test/C03traps.ztst | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'Test/C03traps.ztst') diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 3ef399efd..f75c47c4d 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -183,17 +183,21 @@ } testunset f -1: more sophisticated error trapping + print status $? + unfunction TRAPZERR +0: more sophisticated error trapping >f >ERR-or! >f >t +>f >t >f >ERR-or! >testunset >f >ERR-or! +>status 1 f() { setopt localtraps @@ -216,6 +220,32 @@ fn 1: ksh-style EXIT traps preserve return value - inner() { trap 'return 3' EXIT; return 2: } + inner() { trap 'return 3' EXIT; return 2; } outer() { inner; return 1; } + outer 3: ksh-style EXIT traps can force return status of enclosing function + +# Autoloaded traps are horrid, but unfortunately people expect +# them to work if we support them. + echo "print Running exit trap" >TRAPEXIT + $ZTST_testdir/../Src/zsh -fc ' + fpath=(. $fpath) + autoload TRAPEXIT + print "Exiting, attempt 1" + exit + print "What?" + ' + $ZTST_testdir/../Src/zsh -fc ' + fpath=(. $fpath) + autoload TRAPEXIT; + fn() { print Some function } + fn + print "Exiting, attempt 2" + exit + ' +0: autoloaded TRAPEXIT (exit status > 128 indicates an old bug is back) +>Exiting, attempt 1 +>Running exit trap +>Some function +>Exiting, attempt 2 +>Running exit trap -- cgit 1.4.1