Browse Source

fixes to tmpfile scoping

Jaromil 5 years ago
parent
commit
cb7517e678
1 changed files with 6 additions and 4 deletions
  1. 6 4
      zuper

+ 6 - 4
zuper

@@ -24,7 +24,7 @@
24 24
 ##########################
25 25
 typeset -aU vars
26 26
 typeset -aU arrs
27
-vars=(debug quiet)
27
+vars=(debug quiet ztmpfile)
28 28
 arrs=()
29 29
 
30 30
 debug=${debug:-0}
@@ -219,14 +219,16 @@ endgame() {
219 219
 ##########################
220 220
 # Temp file handling
221 221
 
222
+# ztmp() fills in $ztmpfile global. Caller must copy that variable as
223
+# it will be overwritten at every call.
222 224
 ztmp() {
223 225
     fn ztmp
224 226
 
225
-    _tmp=`mktemp`
226
-    tmpfiles+=($_tmp)
227
-    print $_tmp
227
+    ztmpfile=`mktemp`
228
+    tmpfiles+=($ztmpfile)
228 229
 }
229 230
 
231
+# All tempfiles are freed in endgame()
230 232
 _ztmp_destructor() {
231 233
     fn _ztmp_destructor
232 234