Skip to content

Commit 25a5b3f

Browse files
authored
join: use show_error instead of eprintln (#11932)
1 parent 3dc8794 commit 25a5b3f

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

src/uu/join/src/join.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
// spell-checker:ignore (ToDO) autoformat FILENUM whitespaces pairable unpairable nocheck memmem
6+
// spell-checker:ignore (ToDO) autoformat FILENUM whitespaces nocheck memmem
77

88
use clap::builder::ValueParser;
99
use clap::{Arg, ArgAction, Command};
@@ -18,12 +18,11 @@ use std::os::unix::ffi::OsStrExt;
1818
use thiserror::Error;
1919
use uucore::display::Quotable;
2020
use uucore::error::{FromIo, UError, UResult, USimpleError, set_exit_code};
21-
use uucore::format_usage;
2221
use uucore::i18n::collator::{
2322
AlternateHandling, CollatorOptions, locale_cmp, should_use_locale_collation, try_init_collator,
2423
};
2524
use uucore::line_ending::LineEnding;
26-
use uucore::translate;
25+
use uucore::{format_usage, show_error, translate};
2726

2827
#[derive(Debug, Error)]
2928
enum JoinError {
@@ -650,7 +649,7 @@ impl<'a> State<'a> {
650649
if input.check_order == CheckOrder::Enabled {
651650
return Err(JoinError::UnorderedInput(err_msg));
652651
}
653-
eprintln!("{}: {err_msg}", uucore::execution_phrase());
652+
show_error!("{err_msg}");
654653
self.has_failed = true;
655654
}
656655

@@ -1096,11 +1095,7 @@ fn exec<Sep: Separator>(
10961095
writer.flush()?;
10971096

10981097
if state1.has_failed || state2.has_failed {
1099-
eprintln!(
1100-
"{}: {}",
1101-
uucore::execution_phrase(),
1102-
translate!("join-error-input-not-sorted")
1103-
);
1098+
show_error!("{}", translate!("join-error-input-not-sorted"));
11041099
set_exit_code(1);
11051100
}
11061101
Ok(())

tests/by-util/test_join.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,7 @@ fn wrong_line_order() {
357357
.fails()
358358
.stdout_contains("7 g f 4 fg")
359359
.stderr_is(format!(
360-
"{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n",
361-
ts.bin_path.to_string_lossy(),
360+
"{0}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0}: input is not in sorted order\n",
362361
ts.util_name
363362
));
364363

@@ -383,8 +382,7 @@ fn both_files_wrong_line_order() {
383382
.fails()
384383
.stdout_contains("5 e 3 ef")
385384
.stderr_is(format!(
386-
"{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",
387-
ts.bin_path.to_string_lossy(),
385+
"{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",
388386
ts.util_name
389387
));
390388

0 commit comments

Comments
 (0)