From 80ac2619e43ccd46992bbdf9b573841ed602038e Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 23 Jan 2022 17:32:36 -0500 Subject: [PATCH] dd: correct behavior when status=noxfer Correct the behavior of `dd` with the `status=noxfer` option. Before this commit, the status output was entirely suppressed (as happens with `status=none`). This was incorrect behavior. After this commit, the input/output counts are printed to stderr as expected. For example, $ printf "" | dd status=noxfer 0+0 records in 0+0 records out This commit also updates a unit test that was enforcing the wrong behavior. --- src/uu/dd/src/dd.rs | 9 +++++++-- tests/by-util/test_dd.rs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/uu/dd/src/dd.rs b/src/uu/dd/src/dd.rs index 3e8cd19c4..8032a9ed8 100644 --- a/src/uu/dd/src/dd.rs +++ b/src/uu/dd/src/dd.rs @@ -398,8 +398,13 @@ where } match i.print_level { - Some(StatusLevel::Noxfer) | Some(StatusLevel::None) => {} - _ => print_transfer_stats(&ProgUpdate { + Some(StatusLevel::None) => {} + Some(StatusLevel::Noxfer) => print_io_lines(&ProgUpdate { + read_stat: rstat, + write_stat: wstat, + duration: start.elapsed(), + }), + Some(StatusLevel::Progress) | None => print_transfer_stats(&ProgUpdate { read_stat: rstat, write_stat: wstat, duration: start.elapsed(), diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index dd4204e2e..4fa8c861c 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -183,7 +183,7 @@ fn test_final_stats_noxfer() { new_ucmd!() .args(&["status=noxfer"]) .succeeds() - .stderr_only(""); + .stderr_only("0+0 records in\n0+0 records out\n"); } #[test]