Repository navigation
uniq: preserve complete lines on read errors - #15361
Open
sunsss123soldier wants to merge 1 commit into
Open
sunsss123soldier wants to merge 1 commit into
sunsss123soldier wants to merge 1 commit into
Conversation
sylvestre
reviewed
Oct 15, 2026
|
|
||
| if (group_count == 1 && !self.repeats_only) || (group_count > 1 && !self.uniques_only) { | ||
| // Counts and filtering require the group to end; a read error does not end it. | ||
| if (read_result.is_ok() || !(self.show_counts || self.repeats_only || self.uniques_only)) |
Contributor
There was a problem hiding this comment.
this condition is hard to read, could you please split it into a named bool?
Contributor
Author
There was a problem hiding this comment.
I will split this condition into named boolean variables in the next commit.
sylvestre
reviewed
Oct 15, 2026
| } | ||
| } | ||
|
|
||
| fn uniq() -> Uniq { |
Contributor
There was a problem hiding this comment.
seems like a too generic function name, maybe default_uniq?
sylvestre
reviewed
Oct 15, 2026
| uniq.repeats_only = true; | ||
| check_read_error(&uniq, b"alpha\nalpha\n", b""); | ||
| uniq.all_repeated = true; | ||
| check_read_error(&uniq, b"alpha\nalpha\n", b"alpha\n"); |
Contributor
There was a problem hiding this comment.
with -D we print half of the group here, is it really what we want?
Contributor
Author
There was a problem hiding this comment.
I checked GNU coreutils 9.12 with two complete identical lines followed by an injected read error: uniq -D prints one line and exits with status 1. This was also uutils’ behavior before this PR, so I preserved it for compatibility.
Keep the pending complete line when a later input read fails, and flush processed output before returning the read error. Preserve the existing handling of incomplete records and groups requiring counts or filtering. Add deterministic regression tests with an injected read failure.
sunsss123soldier
force-pushed
the
codex/uniq-preserve-data-on-read-error
branch
from
October 16, 2026 10:52
faa4ee9 to
81c9c0d
Compare
This branch has not been deployed
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.
A read error made uniq return before writing its last complete input line. Preserve and flush that output before returning the error, with regression tests covering incomplete records, grouping, and count/filter modes.
Closes #13094.