Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/freebsd-src.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2022-11-09 09:02:25 +0300
committerKyle Evans <kevans@FreeBSD.org>2022-11-09 09:04:04 +0300
commitd22f03636be1c012951f744f414b0d410970808e (patch)
treef1c5db3628170fac363f54c564aa8c11d215f600 /usr.bin
parent83286682f8485cfaa6ce96e2d43ffbea4a580752 (diff)
mktemp: skip later TMPDIR check if -p is specified
We already did the necessary $TMPDIR fallback, if it's going to be used. Skip the later check so that we don't accidentally override our -p argument. Fixes: ac6f924e1c ("mktemp: add -p/--tmpdir argument") Sponsored by: Klara, Inc.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mktemp/mktemp.c6
-rwxr-xr-xusr.bin/mktemp/tests/mktemp_test.sh2
2 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/mktemp/mktemp.c b/usr.bin/mktemp/mktemp.c
index 6f5b21ce70d5..226084fefb49 100644
--- a/usr.bin/mktemp/mktemp.c
+++ b/usr.bin/mktemp/mktemp.c
@@ -85,6 +85,12 @@ main(int argc, char **argv)
tmpdir = optarg;
if (tmpdir == NULL || *tmpdir == '\0')
tmpdir = getenv("TMPDIR");
+
+ /*
+ * We've already done the necessary environment
+ * fallback, skip the later one.
+ */
+ prefer_tmpdir = false;
break;
case 'q':
diff --git a/usr.bin/mktemp/tests/mktemp_test.sh b/usr.bin/mktemp/tests/mktemp_test.sh
index 60555f1b561b..505c60536b34 100755
--- a/usr.bin/mktemp/tests/mktemp_test.sh
+++ b/usr.bin/mktemp/tests/mktemp_test.sh
@@ -69,7 +69,7 @@ tmpdir_pflag_body()
# Finally, combined -p -t
atf_check -o match:"^$pflag/foo\..+$" \
env -u TMPDIR mktemp -p "$pflag" -t foo
- atf_check -o match:"^$tmpdir/foo\..+$" \
+ atf_check -o match:"^$pflag/foo\..+$" \
env TMPDIR="$tmpdir" mktemp -p "$pflag" -t foo
}