Skip to content

sort: write empty file when input is empty#11969

Open
hideyosh1 wants to merge 1 commit intouutils:mainfrom
hideyosh1:main
Open

sort: write empty file when input is empty#11969
hideyosh1 wants to merge 1 commit intouutils:mainfrom
hideyosh1:main

Conversation

@hideyosh1
Copy link
Copy Markdown
Contributor

@hideyosh1 hideyosh1 commented Apr 24, 2026

  • adds implementations for this behavior in both threaded and wasi

  • adds test for this behavior

Closes #11958

sorry, this is my first contribution, be gentle please...

@hideyosh1 hideyosh1 changed the title sort: write empty file when input is empty (#11958) sort: write empty file when input is empty Apr 24, 2026
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.

Does this even compile? "chunk" is being used before the definition a few lines later.

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.

Or can we merge ReadResult::EmptyInput => { logic to another => for simplicity?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

how so ? just creating a new chunk and passing ReadResult::SortedSingleChunk(first_chunk) ?
but this seems very unwieldy and slow

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.

Something like this might avoid a heap allocation? Not sure it matters.

ReadResult::EmptyInput => {
    print_sorted(std::iter::empty::<&[u8]>(), settings, output)?;
}

@hideyosh1
Copy link
Copy Markdown
Contributor Author

thanks for your review, i think ive fixed these issues... instead i used
iter::empty(); this is fine?

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 24, 2026

Merging this PR will not alter performance

✅ 11 untouched benchmarks
⏩ 345 skipped benchmarks1


Comparing hideyosh1:main (6426bc7) with main (17f1777)

Open in CodSpeed

Footnotes

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

* adds implementations for this behavior in both threaded and wasi

* adds test for this behavior

Co-authored-by: Chad Brewbaker <crb002@gmail.com>
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.

sort -o inconsistency between uutils and gnu coreutils

3 participants