join: use show_error instead of eprintln (#11932)

This commit is contained in:
Daniel Hofstetter
2026-04-23 09:41:19 +02:00
committed by GitHub
parent 3dc8794ada
commit 25a5b3f0b9
2 changed files with 6 additions and 13 deletions
+4 -9
View File
@@ -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<Sep: Separator>(
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(())
+2 -4
View File
@@ -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
));