diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index a8fa90183bb..4e840c47b54 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -92,6 +92,7 @@ struct StatPrinter { time_format: String, line_ending: LineEnding, summarize: bool, + total_text: String, } #[derive(PartialEq, Clone)] @@ -546,11 +547,7 @@ impl StatPrinter { } if self.total { - print!( - "{}\t{}", - self.convert_size(grand_total), - get_message("du-total") - ); + print!("{}\t{}", self.convert_size(grand_total), self.total_text); print!("{}", self.line_ending); } @@ -779,6 +776,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { time, time_format, line_ending: LineEnding::from_zero_flag(matches.get_flag(options::NULL)), + total_text: get_message("du-total"), }; if stat_printer.inodes diff --git a/tests/by-util/test_du.rs b/tests/by-util/test_du.rs index 48043a83117..947236ad86b 100644 --- a/tests/by-util/test_du.rs +++ b/tests/by-util/test_du.rs @@ -1295,3 +1295,25 @@ fn test_du_inodes_blocksize_ineffective() { ); } } + +#[test] +fn test_du_inodes_total_text() { + let ts = TestScenario::new(util_name!()); + let at = &ts.fixtures; + + at.mkdir_all("d/d"); + + let result = ts.ucmd().arg("--inodes").arg("-c").arg("d").succeeds(); + + let lines: Vec<&str> = result.stdout_str().lines().collect(); + + assert_eq!(lines.len(), 3); + + let total_line = lines.last().unwrap(); + assert!(total_line.contains("total")); + + let parts: Vec<&str> = total_line.split('\t').collect(); + assert_eq!(parts.len(), 2); + + assert!(parts[0].parse::().is_ok()); +}