Skip to content

head: fix error message when input is a directory#11541

Merged
cakebaker merged 2 commits intouutils:mainfrom
aguimaraes:head-fix-directory-error-message
Mar 30, 2026
Merged

head: fix error message when input is a directory#11541
cakebaker merged 2 commits intouutils:mainfrom
aguimaraes:head-fix-directory-error-message

Conversation

@aguimaraes
Copy link
Copy Markdown
Contributor

Fixes #11485

head . incorrectly reports:

head: error writing 'standard output': Is a directory

It should report:

head: error reading '.': Is a directory

The cause: io::copy can fail from either the read or write side,but the error was always attributed to stdout via wrap_in_stdout_error.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/basenc/bounded-memory is now passing!
Congrats! The gnu test tests/pr/bounded-memory is now passing!
Congrats! The gnu test tests/unexpand/bounded-memory is now passing!

@cakebaker
Copy link
Copy Markdown
Contributor

The test currently fails on Windows, you probably have to gate it.

@aguimaraes
Copy link
Copy Markdown
Contributor Author

aguimaraes commented Mar 30, 2026

The test currently fails on Windows, you probably have to gate it.

I will try to move the directory check before File::open, using std::path::Path::is_dir(), it should work on Windows too, wdyt?

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 30, 2026

Merging this PR will degrade performance by 4.8%

❌ 1 regressed benchmark
✅ 303 untouched benchmarks
⏩ 46 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation cp_large_file[16] 265.1 µs 278.4 µs -4.8%

Comparing aguimaraes:head-fix-directory-error-message (abbde9e) with main (aab0dda)

Open in CodSpeed

Footnotes

  1. 46 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.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/tty/tty-eof (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)

@cakebaker cakebaker merged commit d868818 into uutils:main Mar 30, 2026
164 of 168 checks passed
@cakebaker
Copy link
Copy Markdown
Contributor

Thanks!

@aguimaraes aguimaraes deleted the head-fix-directory-error-message branch March 30, 2026 15:07
kevinburkesegment pushed a commit to kevinburkesegment/coreutils that referenced this pull request Apr 6, 2026
* head: fix error message when input is a directory

* head: check for directory before trying to open
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.

head . 's error message has wrong meaning

2 participants