From 25a5b3f0b9d2ada55a838a6c0634eb8b22e30268 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Thu, 23 Apr 2026 09:41:19 +0200 Subject: [PATCH] join: use show_error instead of eprintln (#11932) --- src/uu/join/src/join.rs | 13 ++++--------- tests/by-util/test_join.rs | 6 ++---- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/uu/join/src/join.rs b/src/uu/join/src/join.rs index 29d61f59f..ddd565841 100644 --- a/src/uu/join/src/join.rs +++ b/src/uu/join/src/join.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) autoformat FILENUM whitespaces pairable unpairable nocheck memmem +// spell-checker:ignore (ToDO) autoformat FILENUM whitespaces nocheck memmem use clap::builder::ValueParser; use clap::{Arg, ArgAction, Command}; @@ -18,12 +18,11 @@ use std::os::unix::ffi::OsStrExt; use thiserror::Error; use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code}; -use uucore::format_usage; use uucore::i18n::collator::{ AlternateHandling, CollatorOptions, locale_cmp, should_use_locale_collation, try_init_collator, }; use uucore::line_ending::LineEnding; -use uucore::translate; +use uucore::{format_usage, show_error, translate}; #[derive(Debug, Error)] enum JoinError { @@ -650,7 +649,7 @@ impl<'a> State<'a> { if input.check_order == CheckOrder::Enabled { return Err(JoinError::UnorderedInput(err_msg)); } - eprintln!("{}: {err_msg}", uucore::execution_phrase()); + show_error!("{err_msg}"); self.has_failed = true; } @@ -1096,11 +1095,7 @@ fn exec( writer.flush()?; if state1.has_failed || state2.has_failed { - eprintln!( - "{}: {}", - uucore::execution_phrase(), - translate!("join-error-input-not-sorted") - ); + show_error!("{}", translate!("join-error-input-not-sorted")); set_exit_code(1); } Ok(()) diff --git a/tests/by-util/test_join.rs b/tests/by-util/test_join.rs index b19b16199..fbb6e88d3 100644 --- a/tests/by-util/test_join.rs +++ b/tests/by-util/test_join.rs @@ -357,8 +357,7 @@ fn wrong_line_order() { .fails() .stdout_contains("7 g f 4 fg") .stderr_is(format!( - "{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n", - ts.bin_path.to_string_lossy(), + "{0}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0}: input is not in sorted order\n", ts.util_name )); @@ -383,8 +382,7 @@ fn both_files_wrong_line_order() { .fails() .stdout_contains("5 e 3 ef") .stderr_is(format!( - "{0} {1}: fields_5.txt:4: is not sorted: 3\n{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n", - ts.bin_path.to_string_lossy(), + "{0}: fields_5.txt:4: is not sorted: 3\n{0}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0}: input is not in sorted order\n", ts.util_name ));