du: adapt error msg to match GNU's

This commit is contained in:
Daniel Hofstetter 2024-01-30 10:00:30 +01:00
parent a5e611eb06
commit d1e1e9ce0f
2 changed files with 9 additions and 5 deletions

View file

@ -785,8 +785,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.send(Err(USimpleError::new(
1,
format!(
"{}: No such file or directory",
path.to_string_lossy().maybe_quote()
"cannot access {}: No such file or directory",
path.to_string_lossy().quote()
),
)))
.map_err(|e| USimpleError::new(1, e.to_string()))?;

View file

@ -173,11 +173,15 @@ fn test_du_with_posixly_correct() {
}
#[test]
fn test_du_basics_bad_name() {
fn test_du_non_existing_files() {
new_ucmd!()
.arg("bad_name")
.arg("non_existing_a")
.arg("non_existing_b")
.fails()
.stderr_only("du: bad_name: No such file or directory\n");
.stderr_only(concat!(
"du: cannot access 'non_existing_a': No such file or directory\n",
"du: cannot access 'non_existing_b': No such file or directory\n"
));
}
#[test]