From abf4c69b281dfd7f275c2a0101de09c0df41c947 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 25 Jul 2021 13:55:24 -0400 Subject: [PATCH] tac: correct error message when reading from dir. Correct the error message produced by `tac` when trying to read from a directory. Previously if the path 'a' referred to a directory, then running `tac a` would produce the error message dir: read error: Invalid argument after this commit it produces a: read error: Invalid argument which matches GNU `tac`. --- src/uu/tac/src/tac.rs | 2 +- tests/by-util/test_tac.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index ae1fd9bc5..ad3badff4 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -97,7 +97,7 @@ fn tac(filenames: Vec, before: bool, _: bool, separator: &str) -> i32 { let path = Path::new(filename); if path.is_dir() || path.metadata().is_err() { if path.is_dir() { - show_error!("dir: read error: Invalid argument"); + show_error!("{}: read error: Invalid argument", filename); } else { show_error!( "failed to open '{}' for reading: No such file or directory", diff --git a/tests/by-util/test_tac.rs b/tests/by-util/test_tac.rs index a8adbb28e..a16988acf 100644 --- a/tests/by-util/test_tac.rs +++ b/tests/by-util/test_tac.rs @@ -66,5 +66,5 @@ fn test_invalid_input() { .ucmd() .arg("a") .fails() - .stderr_contains("dir: read error: Invalid argument"); + .stderr_contains("a: read error: Invalid argument"); }