+2024-06-11 Paul Eggert <eggert@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 Collin Funk <collin.funk1@gmail.com>
mktempd: Invoke mktemp portably.
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.
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 &&