[klibc] [PATCH] dash: mkbuiltins: Prefere mktemp over tempfile
Ben Hutchings
ben at decadent.org.uk
Tue Apr 27 15:06:38 PDT 2021
On Wed, 2021-01-06 at 19:09 -0800, Carlos Llamas wrote:
> Fixes warning about deprecated tempfile usage:
> WARNING: tempfile is deprecated; consider using mktemp instead.
>
> Signed-off-by: Carlos Llamas <cmllamas at google.com>
Thanks for reminding me of this, and sorry for this delayed response.
I'm actually going to pick the dash upstream change, which is a one-
liner, rather than apply this and diverge from upstream.
Ben.
> ---
> 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
>
--
Ben Hutchings
Klipstein's 4th Law of Prototyping and Production:
A fail-safe circuit will destroy others.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://lists.zytor.com/archives/klibc/attachments/20210428/83edc546/attachment.sig>
More information about the klibc
mailing list