simplified, endgame() now implicitly called by zshexit at end of execution

This commit is contained in:
Jaromil 2015-03-22 11:08:45 +01:00
parent c59ed6b7bd
commit 3d0ff5d069
2 changed files with 6 additions and 13 deletions

View File

@ -104,8 +104,7 @@ for i in ${(k)mymap}; do
print "$i \t ${mymap[$i]}" print "$i \t ${mymap[$i]}"
done done
# end the program (call destructors) # end of the program (will call destructors)
endgame
``` ```

16
zuper
View File

@ -25,7 +25,7 @@
typeset -aU vars typeset -aU vars
typeset -aU arrs typeset -aU arrs
vars=(debug quiet ztmpfile) vars=(debug quiet ztmpfile)
arrs=() arrs=(req freq)
debug=${debug:-0} debug=${debug:-0}
quiet=${quiet:-0} quiet=${quiet:-0}
@ -124,17 +124,8 @@ function _print() {
} }
fn() { fn() {
local msg="$1" fun="$@"
command -v gettext 1>/dev/null 2>/dev/null \
&& msg="$(gettext -s "$1")"
for i in $(seq 2 ${#}); do
msg=${(S)msg//::$(($i - 1))*::/$*[$i]}
done
fun="$msg"
func "$fun"
req=() req=()
freq=() freq=()
} }
@ -215,6 +206,9 @@ endgame() {
return 0 return 0
} }
# Register endgame() to be called at exit.
# unlike TRAPEXIT, the zshexit() hook is not called when functions exit.
zshexit() { endgame EXIT; return $? }
########################## ##########################
# Temp file handling # Temp file handling