Skip to content

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

Open
MannXo wants to merge 1 commit into
uutils:mainfrom
MannXo:fix/15790-mktemp-empty-tmpdir-template
Open

MannXo wants to merge 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

This branch has not been deployed

No deployments
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

1 participant