Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uniq: almost fix gnu test #3417

Merged
merged 2 commits into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/uu/uniq/src/uniq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::path::Path;
use std::str::FromStr;
use strum_macros::{AsRefStr, EnumString};
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::format_usage;

static ABOUT: &str = "Report or omit repeated lines.";
Expand Down Expand Up @@ -284,6 +284,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
ignore_case: matches.is_present(options::IGNORE_CASE),
zero_terminated: matches.is_present(options::ZERO_TERMINATED),
};

if uniq.show_counts && uniq.all_repeated {
return Err(UUsageError::new(
1,
"printing all duplicated lines and repeat counts is meaningless",
));
}

uniq.print_uniq(
&mut open_input_file(&in_file_name)?,
&mut open_output_file(&out_file_name)?,
Expand Down
Loading