From 487c874204ed45209f6f9c095a3f11106ab67e14 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sun, 17 Apr 2022 16:32:01 +0200 Subject: [PATCH] uniq: print warning when both `-D` and `-c` are passed --- src/uu/uniq/src/uniq.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/uu/uniq/src/uniq.rs b/src/uu/uniq/src/uniq.rs index 020de0230..32e0783ce 100644 --- a/src/uu/uniq/src/uniq.rs +++ b/src/uu/uniq/src/uniq.rs @@ -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."; @@ -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)?,