Skip to content

mktemp: treat an empty TMPDIR as unset - #16041

Merged
sylvestre merged 2 commits into
uutils:mainfrom
Logic769:mktemp-empty-tmpdir
Nov 2, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
Logic769:mktemp-empty-tmpdir

Conversation

@Logic769

Copy link
Copy Markdown
Contributor

When TMPDIR is set to an empty string, GNU mktemp treats it as
unset and falls back to the system default temporary directory (or to
-p). uutils instead used the empty value as the directory, so
mktemp -t fooXXX created the file in the current directory and even
ignored an explicit -p DIR.

Treat an empty TMPDIR as unset in the template code path, while
keeping the existing precedence where a non-empty TMPDIR wins over
-p when -t is given.

Tests cover -t, --tmpdir, -d -t, and -p DIR -t with an empty
TMPDIR.

Closes #15790

@sylvestre

Copy link
Copy Markdown
Contributor

@Logic769 again, please stop...
(and it has the ls change here...)

@codspeed

codspeed Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 7.8%

1 warning, 1 note

⚠️ 123 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

⚡ 1 improved benchmark
✅ 400 untouched benchmarks
⏩ 70 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation sort_long_line[10000] 1.1 ms 1 ms +7.8%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Logic769:mktemp-empty-tmpdir (83583d6) with main (9cc868b)

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@Logic769
Logic769 force-pushed the mktemp-empty-tmpdir branch from 95b7471 to 2e9169b Compare October 30, 2026 13:02
@Logic769
Logic769 force-pushed the mktemp-empty-tmpdir branch from 2e9169b to 1f55473 Compare October 30, 2026 13:04
Comment thread tests/by-util/test_mktemp.rs Resolved
@sylvestre
sylvestre merged commit 6fe1d1a into uutils:main Nov 2, 2026
191 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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

2 participants