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.
This commit is contained in:
Kyle Evans 2022-11-09 00:02:25 -06:00
parent 83286682f8
commit d22f03636b
2 changed files with 7 additions and 1 deletions

View file

@ -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':

View file

@ -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
}