doexe/newins: mktemp for bug #484332
authorZac Medico <zmedico@gentoo.org>
Mon, 9 Sep 2013 17:42:54 +0000 (10:42 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 9 Sep 2013 17:42:54 +0000 (10:42 -0700)
bin/ebuild-helpers/doexe
bin/ebuild-helpers/newins

index aa050e9ed417591fc0332756ce0b4d7d466de264..c34fcae74999bd2ae8f96c831e5bab41745ae115 100755 (executable)
@@ -17,8 +17,7 @@ if [[ ! -d ${ED}${_E_EXEDESTTREE_} ]] ; then
        install -d "${ED}${_E_EXEDESTTREE_}"
 fi
 
-TMP=$T/.doexe_tmp
-mkdir "$TMP"
+TMP=$(mktemp -d "${T}/.doexe_tmp_XXXXXX")
 
 ret=0
 
index 3538f70603c1c76d0d85880b736750139c440713..03359851a5a12afac458e0e297ef9954a95c9617 100755 (executable)
@@ -19,14 +19,15 @@ if ___eapi_newins_supports_reading_from_standard_input && [[ $1 == "-" ]]; then
        stdin=yes
 fi
 
-rm -rf "${T}/$2"
+TMP=$(mktemp -d "${T}/.newins_tmp_XXXXXX")
+trap 'rm -rf "${TMP}"' EXIT
 
 if [[ ${stdin} ]] ; then
        if [[ -t 0 ]] ; then
                __helpers_die "!!! ${helper}: Input is from a terminal"
                exit 1
        fi
-       cat > "${T}/$2"
+       cat > "${TMP}/$2"
        ret=$?
 else
        if [[ ! -e $1 ]] ; then
@@ -41,7 +42,7 @@ else
                fi
        fi
 
-       cp ${cp_args} "$1" "${T}/$2"
+       cp ${cp_args} "$1" "${TMP}/$2"
        ret=$?
 fi
 
@@ -50,8 +51,7 @@ if [[ ${ret} -ne 0 ]] ; then
        exit ${ret}
 fi
 
-do${helper#new} "${T}/$2"
+do${helper#new} "${TMP}/$2"
 ret=$?
-rm -rf "${T}/${2}"
 [[ $ret -ne 0 ]] && __helpers_die "${helper} failed"
 exit $ret