From c6e044927c95fbeab5364349e9e1e7d1e09158e9 Mon Sep 17 00:00:00 2001 From: Michael Debertol Date: Sun, 25 Jul 2021 22:25:54 +0200 Subject: [PATCH] sort: print check messages to stderr, not stdout --- src/uu/sort/src/check.rs | 4 ++-- tests/by-util/test_sort.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uu/sort/src/check.rs b/src/uu/sort/src/check.rs index f1cd22686..44c71674e 100644 --- a/src/uu/sort/src/check.rs +++ b/src/uu/sort/src/check.rs @@ -56,7 +56,7 @@ pub fn check(path: &str, settings: &GlobalSettings) -> i32 { ) == Ordering::Greater { if !settings.check_silent { - println!("sort: {}:{}: disorder: {}", path, line_idx, new_first.line); + eprintln!("sort: {}:{}: disorder: {}", path, line_idx, new_first.line); } return 1; } @@ -68,7 +68,7 @@ pub fn check(path: &str, settings: &GlobalSettings) -> i32 { if compare_by(a, b, settings, chunk.line_data(), chunk.line_data()) == Ordering::Greater { if !settings.check_silent { - println!("sort: {}:{}: disorder: {}", path, line_idx, b.line); + eprintln!("sort: {}:{}: disorder: {}", path, line_idx, b.line); } return 1; } diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index e594de0a7..1add0bb54 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -181,7 +181,7 @@ fn test_check_zero_terminated_failure() { .arg("-c") .arg("zero-terminated.txt") .fails() - .stdout_is("sort: zero-terminated.txt:2: disorder: ../../fixtures/du\n"); + .stderr_only("sort: zero-terminated.txt:2: disorder: ../../fixtures/du\n"); } #[test] @@ -775,13 +775,13 @@ fn test_check() { .arg(diagnose_arg) .arg("check_fail.txt") .fails() - .stdout_is("sort: check_fail.txt:6: disorder: 5\n"); + .stderr_only("sort: check_fail.txt:6: disorder: 5\n"); new_ucmd!() .arg(diagnose_arg) .arg("multiple_files.expected") .succeeds() - .stdout_is(""); + .stderr_is(""); } }