about summary refs log tree commit diff
diff options
context:
space:
mode:
-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);