Fix test function mktemp to avoid false errors

If called within a temporary directory that had an X in the path, it
would fail. This caused sporadic CI test failures.
This commit is contained in:
Mahmoud Al-Qudsi
2021-08-08 21:01:10 -05:00
committed by Johannes Altmanninger
parent e96b6e157c
commit c52f372a8c

View File

@@ -52,19 +52,16 @@ function mktemp
# So let's outlaw them anywhere besides the end.
# Similarly GNU mktemp requires at least 3 X's, BSD mktemp requires none. Let's require 3.
begin
set -l chars (string split '' -- $template)
set -l found_x
for c in $chars
if test $c = X
set found_x $found_x X
else if set -q found_x[1]
echo 'mktemp: X\'s may only occur at the end of the template' >&2
_mktemp_help >&2
exit 1
end
# Look for at least three Xs that are not the end of the template
if string match -rq -- 'XXX[^X].*$' "$template"
echo "mktemp: X's may only occur at the end of the template '$template'" >&2
_mktemp_help >&2
exit 1
end
if test (count $found_x) -lt 3
echo "mktemp: too few X's in template '$template'" >&2
# Look for too few X incidences at the end of the template
if ! string match -rq -- 'XXX$' "$template"
echo "mktemp: too few trailing X's in template '$template'" >&2
_mktemp_usage >&2
exit 1
end