Repository navigation
Revert "mktemp: treat an empty TMPDIR as unset" - #16136
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 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
TMPDIRwith 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Reverts #16041
duplicated pr
please don't do that @Logic769 in the future