about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-05 02:56:15 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-05 02:56:15 +0000
commitf8af0b7ee44fed3f40e4c644f3cfa69468f2db12 (patch)
tree90b50d995718467633cc384625168a8ca8761183
parent17eda071fe660ae704ed9bb48c3558ca73e4eb22 (diff)
downloadzsh-f8af0b7ee44fed3f40e4c644f3cfa69468f2db12.tar.gz
zsh-f8af0b7ee44fed3f40e4c644f3cfa69468f2db12.tar.xz
zsh-f8af0b7ee44fed3f40e4c644f3cfa69468f2db12.zip
Merge of 22992: make $? available on trap or hook shell exit.
-rw-r--r--Doc/Zsh/builtins.yo2
-rw-r--r--Src/builtin.c1
2 files changed, 3 insertions, 0 deletions
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 30d2cf84b..de5a96ea2 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -1198,6 +1198,8 @@ after each command.
 If var(sig) is tt(0) or tt(EXIT)
 and the tt(trap) statement is executed inside the body of a function,
 then the command var(arg) is executed after the function completes.
+The value of tt($?) at the start of execution is the exit status of the
+shell or the return status of the function exiting.
 If var(sig) is tt(0) or tt(EXIT)
 and the tt(trap) statement is not executed inside the body of a function,
 then the command var(arg) is executed when the shell terminates.
diff --git a/Src/builtin.c b/Src/builtin.c
index 40e2f8145..cda6f0198 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -4229,6 +4229,7 @@ zexit(int val, int from_where)
 #endif
 	}
     }
+    lastval = val;
     if (sigtrapped[SIGEXIT])
 	dotrap(SIGEXIT);
     runhookdef(EXITHOOK, NULL);