diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2006-11-10 09:59:26 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2006-11-10 09:59:26 +0000 |
commit | 254b3f1a6b85e6cfefe21fea3d81c3f97c003ec2 (patch) | |
tree | 08450909fc3a75be4a8faa6f3b848473fea5c979 | |
parent | 7929d97254f84932ab79baf613f3f300ca0a5f84 (diff) | |
download | zsh-254b3f1a6b85e6cfefe21fea3d81c3f97c003ec2.tar.gz zsh-254b3f1a6b85e6cfefe21fea3d81c3f97c003ec2.tar.xz zsh-254b3f1a6b85e6cfefe21fea3d81c3f97c003ec2.zip |
22992: make $? available in exit traps/hooks
22993: slightly more effective _make variable fix
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | Completion/Unix/Command/_make | 10 | ||||
-rw-r--r-- | Doc/Zsh/builtins.yo | 2 | ||||
-rw-r--r-- | Doc/Zsh/func.yo | 2 | ||||
-rw-r--r-- | Src/builtin.c | 1 |
5 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index d7f38744b..d52cbd0f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-11-10 Peter Stephenson <pws@csr.com> + + * 22993: Completion/Unix/Command/_make: slightly more + effective version of 22988. + + * 22992: Doc/Zsh/func.yo, Doc/Zsh/builtins.yo, Src/builtin.c: + make $? available on trap or hook shell exit. + 2006-11-09 Peter Stephenson <pws@csr.com> * 22984: Doc/Zsh/func.yo, Src/builtin.c: add zshexit hook diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 91c434559..93d4b52da 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -51,6 +51,12 @@ expandVars() { done } +# parseMakefile only runs inside $(...), so it doesn't matter that +# it pollutes the global namespace, setting zsh variables to +# make variables. The difficult case is where a make variable +# is special in zsh; we use local -h to hide those. This +# isn't a complete solution since it means variables defined in +# included Makefiles are undefined before returning to the parent. parseMakefile() { local input var val TAB=$'\t' dir=$1 @@ -60,7 +66,7 @@ parseMakefile() { var=${input%%[ $TAB]#=*} val=${input#*=} val=${val##[ $TAB]#} - local -h $var + [[ ${(tP)var} = *special ]] && local -h $var eval $var=\$val ;; ([[:alnum:]][[:alnum:]_]#[ $TAB]#:=*) @@ -68,7 +74,7 @@ parseMakefile() { val=${input#*=} val=${val##[ $TAB]#} val=$(expandVars 10 $val) - local -h $var + [[ ${(tP)var} = *special ]] && local -h $var eval $var=\$val ;; ([[:alnum:]][^$TAB:=]#:[^=]*) diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 820888ac3..27f91e8b6 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -1252,6 +1252,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/Doc/Zsh/func.yo b/Doc/Zsh/func.yo index 74d031fd1..16a838f9d 100644 --- a/Doc/Zsh/func.yo +++ b/Doc/Zsh/func.yo @@ -248,6 +248,8 @@ findex(TRAPEXIT) item(tt(TRAPEXIT))( Executed when the shell exits, or when the current function exits if defined inside a function. +The value of tt($?) at the start of execution is the exit status of the +shell or the return status of the function exiting. ) findex(TRAPZERR) findex(TRAPERR) diff --git a/Src/builtin.c b/Src/builtin.c index 70de5bcec..85c961e3d 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -4434,6 +4434,7 @@ zexit(int val, int from_where) #endif } } + lastval = val; if (sigtrapped[SIGEXIT]) dotrap(SIGEXIT); callhookfunc("zshexit", NULL, 1); |