Skip to content

mktemp: treat empty TMPDIR as unset with a template - #15836

Merged
sylvestre merged 1 commit into
uutils:mainfrom
MannXo:fix/15790-mktemp-empty-tmpdir-template
Nov 2, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
MannXo:fix/15790-mktemp-empty-tmpdir-template

Conversation

@MannXo

@MannXo MannXo commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

With TMPDIR set to the empty string, mktemp -t T, mktemp -d -t T, mktemp --tmpdir T and mktemp -p DIR -t T created the file in the current directory and printed a bare name. GNU treats an empty TMPDIR as unset.

The template arm of Options::from now ignores an empty TMPDIR for -t, and its fallback goes through get_tmpdir_env_or_default(), the helper the no-template path already uses. That also lets -p DIR apply when TMPDIR is empty, and removes the duplicated WASI branch.

$ TMPDIR= mktemp -t fooXXX
/tmp/foo3E8
$ TMPDIR= mktemp -p /tmp/cu-other -t fooXXX
/tmp/cu-other/foorbO

Before, these printed foorx8 and fooUlY, created in the current directory.

test_empty_tmpdir_env_var_with_template covers all four forms and fails on main.

Closes #15790

@cakebaker

Copy link
Copy Markdown
Contributor

I'm sorry, #16041 got merged even though this PR was first. Anyway, thanks for your PR!

@cakebaker cakebaker closed this Nov 2, 2026
@sylvestre

sylvestre commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

actually, let me revert the other

@sylvestre sylvestre reopened this Nov 2, 2026
@sylvestre
sylvestre merged commit 5a4cfcc into uutils:main Nov 2, 2026
137 of 139 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

sorry about that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mktemp: -t and --tmpdir with a template use cwd when TMPDIR is empty

3 participants