[klibc] [PATCH] dash: mkbuiltins: Prefere mktemp over tempfile

Carlos Llamas
Thu, 07 Jan 2021 03:09:34 -0000

Fixes warning about deprecated tempfile usage:
WARNING: tempfile is deprecated; consider using mktemp instead.

Signed-off-by: Carlos Llamas <cmllamas at google.com>
---
 usr/dash/mkbuiltins | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/usr/dash/mkbuiltins b/usr/dash/mkbuiltins
index 70308bd8..a3d69332 100644
--- a/usr/dash/mkbuiltins
+++ b/usr/dash/mkbuiltins
@@ -35,9 +35,9 @@
 #
 #	@(#)mkbuiltins	8.2 (Berkeley) 5/4/95

-tempfile=tempfile
-if ! type tempfile > /dev/null 2>&1 && ! type mktemp >
/dev/null 2>&1; then
-	_my_tempfile()
+mktemp="mktemp ${TMPDIR:-/tmp}/builtin.XXXXXX"
+if ! type mktemp > /dev/null 2>&1 && ! type tempfile >
/dev/null 2>&1; then
+	_my_mktemp()
 	{
 		local index=0
 		while test -f "${TMPDIR:-/tmp}/builtin.$$.$index"; do
@@ -48,14 +48,14 @@ if ! type tempfile > /dev/null 2>&1 && !
type mktemp > /dev/null 2>&1; then
 		echo "${TMPDIR:-/tmp}/builtin.$$.$index"
 	}

-	tempfile="_my_tempfile"
-elif ! type tempfile > /dev/null 2>&1; then
-	tempfile="mktemp ${TMPDIR:-/tmp}/builtin.XXXXXX"
+	mktemp="_my_mktemp"
+elif ! type mktemp > /dev/null 2>&1; then
+	mktemp="tempfile -p builtin."
 fi

 trap 'rm -f $temp $temp2' EXIT
-temp=$($tempfile)
-temp2=$($tempfile)
+temp=$($mktemp)
+temp2=$($mktemp)

 builtins=$1

--
2.29.2.729.g45daf8777d-goog