]> git.decadent.org.uk Git - dak.git/blobdiff - config/debian/common
New function for tempfile generation
[dak.git] / config / debian / common
index 0177f1f6fcfd8e1a14b94f32d69a5975607946e1..a568d82657b0e559c55b838f708054473f0cdc75 100644 (file)
@@ -23,6 +23,19 @@ function debug () {
     fi
 }
 
+# Get a tempfile, add it to the right variable to get rid of it,
+# and return it
+function gettempfile() {
+    local MAKEDIR=${1:-false}
+    local TMPARGS=""
+    if [[ ${MAKEDIR} == true ]]; then
+        TMPARGS="--directory"
+    fi
+    local TMPFILE=$( mktemp -p ${TMPDIR} ${TMPARGS} )
+    TMPFILES="${TEMPFILES} ${TMPFILE}"
+    echo "${TMPFILE}"
+}
+
 # Function that only cleans tempfiles, but does not exit or otherwise
 # care about any exit status
 function cleantempfiles() {