diff --git a/README.md b/README.md index af03e54..b85b8d3 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,7 @@ for i in ${(k)mymap}; do print "$i \t ${mymap[$i]}" done -# end the program (call destructors) -endgame +# end of the program (will call destructors) ``` diff --git a/zuper b/zuper index d4a9112..8f9fbcc 100644 --- a/zuper +++ b/zuper @@ -25,7 +25,7 @@ typeset -aU vars typeset -aU arrs vars=(debug quiet ztmpfile) -arrs=() +arrs=(req freq) debug=${debug:-0} quiet=${quiet:-0} @@ -124,17 +124,8 @@ function _print() { } - fn() { - local msg="$1" - 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" + fun="$@" req=() freq=() } @@ -215,6 +206,9 @@ endgame() { 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