diff --git a/src/uu/du/src/du.rs b/src/uu/du/src/du.rs index 03cfb23e580..e3f5a718654 100644 --- a/src/uu/du/src/du.rs +++ b/src/uu/du/src/du.rs @@ -588,6 +588,7 @@ pub fn div_ceil(a: u64, b: u64) -> u64 { (a + b - 1) / b } +// Read file paths from the specified file, separated by null characters fn read_files_from(file_name: &str) -> Result, std::io::Error> { let reader: Box = if file_name == "-" { // Read from standard input @@ -656,7 +657,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .into()); } - // Read file paths from the specified file, separated by null characters read_files_from(file_from)? } else { match matches.get_one::(options::FILE) { diff --git a/tests/by-util/test_du.rs b/tests/by-util/test_du.rs index 20fca62cc92..7b0dc9a4d89 100644 --- a/tests/by-util/test_du.rs +++ b/tests/by-util/test_du.rs @@ -992,3 +992,16 @@ fn test_du_files0_from_dir() { let result = ts.ucmd().arg("--files0-from=dir").fails(); assert_eq!(result.stderr_str(), "du: dir: read error: Is a directory\n"); } + +#[test] +fn test_du_files0_from_combined() { + let ts = TestScenario::new(util_name!()); + let at = &ts.fixtures; + + at.mkdir("dir"); + + let result = ts.ucmd().arg("--files0-from=-").arg("foo").fails(); + let stderr = result.stderr_str(); + + assert!(stderr.contains("file operands cannot be combined with --files0-from")); +}