mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-07-26 21:51:03 +02:00
22992: make $? available in exit traps/hooks
22993: slightly more effective _make variable fix
This commit is contained in:
parent
7929d97254
commit
254b3f1a6b
5 changed files with 21 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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:=]#:[^=]*)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -4434,6 +4434,7 @@ zexit(int val, int from_where)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
lastval = val;
|
||||
if (sigtrapped[SIGEXIT])
|
||||
dotrap(SIGEXIT);
|
||||
callhookfunc("zshexit", NULL, 1);
|
||||
|
|
Loading…
Reference in a new issue