From f8af0b7ee44fed3f40e4c644f3cfa69468f2db12 Mon Sep 17 00:00:00 2001 From: Paul Ackersviller Date: Mon, 5 Nov 2007 02:56:15 +0000 Subject: Merge of 22992: make $? available on trap or hook shell exit. --- Doc/Zsh/builtins.yo | 2 ++ Src/builtin.c | 1 + 2 files changed, 3 insertions(+) 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); -- cgit 1.4.1