On 6/8/24 03:19, Collin Funk wrote:
The change was then reverted since Jim preferred the directory name
created with -t.
Yes, and Jim's point seems good so I tried to resurrect that by
installing the attached patch to use GNU-style mktemp -t without
creating junk directories on NetBSD. Please give it a try.From 5c2e65d9c7605bb9a10cc28e532d39faf857cb5e Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 11 Jun 2024 15:09:55 -0700
Subject: [PATCH] mktempd: use GNU-style -t if available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This better satisfies Jim Meyering’s point in:
https://lists.gnu.org/archive/html/bug-gnulib/2016-03/msg00074.html
that it’s more useful when each temporary test directory name
includes the corresponding test’s name.
* build-aux/mktempd: Try mktemp -t only with GNU syntax, so that
NetBSD mktemp fails. Also, reject templates beginning with "-" so
that they are not treated as options.
* tests/init.sh (mktempd_): Likewise.
---
ChangeLog | 12 ++++++++++++
build-aux/mktempd | 7 +++++--
tests/init.sh | 8 ++++++--
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index caef27ff72..ec9505fc70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-06-11 Paul Eggert <egg...@cs.ucla.edu>
+
+ mktempd: use GNU-style -t if available
+ This better satisfies Jim Meyering’s point in:
+ https://lists.gnu.org/archive/html/bug-gnulib/2016-03/msg00074.html
+ that it’s more useful when each temporary test directory name
+ includes the corresponding test’s name.
+ * build-aux/mktempd: Try mktemp -t only with GNU syntax, so that
+ NetBSD mktemp fails. Also, reject templates beginning with "-" so
+ that they are not treated as options.
+ * tests/init.sh (mktempd_): Likewise.
+
2024-06-11 Bruno Haible <br...@clisp.org>
parse-datetime: Add support for VPATH builds with OpenBSD 'make'.
diff --git a/build-aux/mktempd b/build-aux/mktempd
index 542a4016fe..cc4824a3eb 100755
--- a/build-aux/mktempd
+++ b/build-aux/mktempd
@@ -84,14 +84,17 @@ mktempd()
esac
case $template in
+ -*) die "invalid template: $template (cannot start with '-')";;
*XXXX) ;;
*) die "invalid template: $template (must have a suffix of at least 4 X's)";;
esac
fail=0
- # First, try to use mktemp.
- d=`env -u TMPDIR mktemp -d -p "$destdir" "$template" 2>/dev/null` \
+ # First, try GNU mktemp, where -t has no option-argument.
+ # Put -t last, as GNU mktemp allows, so that the incompatible NetBSD mktemp
+ # (where -t has an option-argument) fails instead of creating a junk dir.
+ d=`env -u TMPDIR mktemp -d -p "$destdir" "$template" -t 2>/dev/null` \
|| fail=1
# The resulting name must be in the specified directory.
diff --git a/tests/init.sh b/tests/init.sh
index 2724f5ab67..237db02fb0 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -338,13 +338,17 @@ mktempd_ ()
esac
case $template_ in
+ -*) fail _ \
+ "invalid template: $template_ (must not begin with '-')";;
*XXXX) ;;
*) fail_ \
"invalid template: $template_ (must have a suffix of at least 4 X's)";;
esac
- # First, try to use mktemp.
- d=`unset TMPDIR; { mktemp -d -p "$destdir_" "$template_"; } 2>/dev/null` &&
+ # First, try GNU mktemp, where -t has no option-argument.
+ # Put -t last, as GNU mktemp allows, so that the incompatible NetBSD mktemp
+ # (where -t has an option-argument) fails instead of creating a junk dir.
+ d=`unset TMPDIR; { mktemp -d -p "$destdir_" "$template_" -t; } 2>/dev/null` &&
# The resulting name must be in the specified directory.
case $d in "$destdir_slash_"*) :;; *) false;; esac &&
--
2.45.2