Skip to content

Revert "mktemp: treat an empty TMPDIR as unset" - #16136

Merged
sylvestre merged 2 commits into
mainfrom
revert-16041-mktemp-empty-tmpdir
Nov 2, 2026
Merged

sylvestre merged 2 commits into
mainfrom
revert-16041-mktemp-empty-tmpdir

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

Reverts #16041
duplicated pr

please don't do that @Logic769 in the future

Copilot AI balanced review requested due to automatic review settings November 2, 2026 15:31
@sylvestre
sylvestre merged commit 9d28273 into main Nov 2, 2026
131 of 132 checks passed
@sylvestre
sylvestre deleted the revert-16041-mktemp-empty-tmpdir branch November 2, 2026 15:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Empty TMPDIR values are no longer filtered out, causing mktemp to use the current directory instead of honoring -p or falling back to /tmp.

2 open issues
What changed in this PR

This PR reverts #16041, identified as a duplicate fix for mktemp handling of an empty TMPDIR when a template is supplied.

Changes:

  • Restores direct environment-based temporary-directory selection in the template path.
  • Removes regression tests for empty TMPDIR with templates and directory-selection options.
File Description
tests/​by-util/​test_mktemp.rs Removes empty-TMPDIR template regression tests.
src/​uu/​mktemp/​src/​mktemp.rs Reverts empty-value filtering and helper-based fallback for templates.

Review effort: Balanced

Some(template) => {
let tmpdir = if let Some(tmpdir) =
env::var_os(TMPDIR_ENV_VAR).filter(|val| !val.is_empty())
let tmpdir = if let Some(tmpdir) = env::var_os(TMPDIR_ENV_VAR)
Comment on lines +143 to +149
#[cfg(target_os = "wasi")]
// WASI's `std::env::temp_dir()` unconditionally panics
let default_tmp_dir = env::var_os(TMPDIR_ENV_VAR)
.map_or_else(|| PathBuf::from(FALLBACK_TMPDIR), PathBuf::from);
#[cfg(not(target_os = "wasi"))]
let default_tmp_dir = env::temp_dir();
Some(default_tmp_dir)
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.

2 participants