Skip to content

Commit

Permalink
Merge pull request #5916 from cakebaker/du_non_existing
Browse files Browse the repository at this point in the history
du: adapt error message to match GNU's
  • Loading branch information
sylvestre authored Jan 30, 2024
2 parents 5aff6ec + d1e1e9c commit 8691ec9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))?;
Expand Down
10 changes: 7 additions & 3 deletions tests/by-util/test_du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 8691ec9

Please sign in to comment.