Browse Source

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

Jaromil 5 years ago
parent
commit
3d0ff5d069
2 changed files with 6 additions and 13 deletions
  1. 1 2
      README.md
  2. 5 11
      zuper

+ 1 - 2
README.md

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

+ 5 - 11
zuper

@@ -25,7 +25,7 @@
25 25
 typeset -aU vars
26 26
 typeset -aU arrs
27 27
 vars=(debug quiet ztmpfile)
28
-arrs=()
28
+arrs=(req freq)
29 29
 
30 30
 debug=${debug:-0}
31 31
 quiet=${quiet:-0}
@@ -124,17 +124,8 @@ function _print() {
124 124
 }
125 125
 
126 126
 
127
-
128 127
 fn() {
129
-    local msg="$1"
130
-    command -v gettext 1>/dev/null 2>/dev/null \
131
-        && msg="$(gettext -s "$1")"
132
-    for i in $(seq 2 ${#}); do
133
-        msg=${(S)msg//::$(($i - 1))*::/$*[$i]}
134
-    done
135
-    
136
-    fun="$msg"
137
-    func "$fun"
128
+    fun="$@"
138 129
     req=()
139 130
     freq=()
140 131
 }
@@ -215,6 +206,9 @@ endgame() {
215 206
     return 0
216 207
 }
217 208
 
209
+# Register endgame() to be called at exit.
210
+# unlike TRAPEXIT, the zshexit() hook is not called when functions exit.
211
+zshexit() { endgame EXIT; return $? }
218 212
 
219 213
 ##########################
220 214
 # Temp file handling