git: d22f03636be1 - main - mktemp: skip later TMPDIR check if -p is specified
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Nov 2022 06:04:18 UTC
The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=d22f03636be1c012951f744f414b0d410970808e commit d22f03636be1c012951f744f414b0d410970808e Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2022-11-09 06:02:25 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2022-11-09 06:04:04 +0000 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. --- usr.bin/mktemp/mktemp.c | 6 ++++++ usr.bin/mktemp/tests/mktemp_test.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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 }