fixes to tmpfile scoping

This commit is contained in:
Jaromil 2015-03-22 10:30:24 +01:00
parent 4b542abc04
commit cb7517e678
1 changed files with 6 additions and 4 deletions

10
zuper
View File

@ -24,7 +24,7 @@
########################## ##########################
typeset -aU vars typeset -aU vars
typeset -aU arrs typeset -aU arrs
vars=(debug quiet) vars=(debug quiet ztmpfile)
arrs=() arrs=()
debug=${debug:-0} debug=${debug:-0}
@ -219,14 +219,16 @@ endgame() {
########################## ##########################
# Temp file handling # Temp file handling
# ztmp() fills in $ztmpfile global. Caller must copy that variable as
# it will be overwritten at every call.
ztmp() { ztmp() {
fn ztmp fn ztmp
_tmp=`mktemp` ztmpfile=`mktemp`
tmpfiles+=($_tmp) tmpfiles+=($ztmpfile)
print $_tmp
} }
# All tempfiles are freed in endgame()
_ztmp_destructor() { _ztmp_destructor() {
fn _ztmp_destructor fn _ztmp_destructor