From 1b97b431cec31cc53dd3c6617f338b65dea48bf9 Mon Sep 17 00:00:00 2001 From: Devel Date: Wed, 12 Aug 2026 10:51:05 +0300 Subject: [PATCH 1/4] strip errno when argument is not a directory but an existing file --- src/uu/pathchk/src/pathchk.rs | 6 +++++- tests/by-util/test_pathchk.rs | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index 635ae6e9820..bb758f35f29 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -255,7 +255,11 @@ fn check_searchable(path: &str) -> bool { if e.kind() == ErrorKind::NotFound { true } else { - writeln!(std::io::stderr(), "{e}"); + writeln!( + std::io::stderr(), + "{}", + format_args!("pathchk: {}: {}", path, uucore::error::strip_errno(&e)) + ); false } } diff --git a/tests/by-util/test_pathchk.rs b/tests/by-util/test_pathchk.rs index 47fb1e01d1b..811bb75a783 100644 --- a/tests/by-util/test_pathchk.rs +++ b/tests/by-util/test_pathchk.rs @@ -180,3 +180,13 @@ fn test_pathchk_non_utf8_paths() { let filename = std::ffi::OsString::from_vec(vec![0xFF, 0xFE]); new_ucmd!().arg(&filename).succeeds(); } + +#[test] +#[cfg(unix)] +fn test_not_a_directory_clean() { + // https://github.com/uutils/coreutils/issues/13888 + new_ucmd!() + .arg("/dev/full/") + .fails() + .stderr_is("pathchk: /dev/full/: Not a directory\n"); +} From c943339fc838484e22a0abc5c091fa3ef4ea7a42 Mon Sep 17 00:00:00 2001 From: Devel Date: Wed, 12 Aug 2026 11:01:33 +0300 Subject: [PATCH 2/4] show_error instead of writeln --- src/uu/pathchk/src/pathchk.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index bb758f35f29..d4ac9c9150a 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -255,11 +255,7 @@ fn check_searchable(path: &str) -> bool { if e.kind() == ErrorKind::NotFound { true } else { - writeln!( - std::io::stderr(), - "{}", - format_args!("pathchk: {}: {}", path, uucore::error::strip_errno(&e)) - ); + uucore::show_error!("{}: {}", path, uucore::error::strip_errno(&e)); false } } From 9eaa015138bfa117f8567a3c250f02cb29f4325e Mon Sep 17 00:00:00 2001 From: Devel Date: Wed, 12 Aug 2026 11:07:16 +0300 Subject: [PATCH 3/4] import strip_errno and showerror --- src/uu/pathchk/src/pathchk.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index d4ac9c9150a..48ecc915c48 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -10,8 +10,10 @@ use std::ffi::OsString; use std::fs; use std::io::{ErrorKind, Write}; use uucore::display::Quotable; +use uucore::error::strip_errno; use uucore::error::{UResult, UUsageError, set_exit_code}; use uucore::format_usage; +use uucore::show_error; use uucore::translate; // operating mode @@ -255,7 +257,7 @@ fn check_searchable(path: &str) -> bool { if e.kind() == ErrorKind::NotFound { true } else { - uucore::show_error!("{}: {}", path, uucore::error::strip_errno(&e)); + show_error!("{}: {}", path, strip_errno(&e)); false } } From 73a3d7c981beda4e9838690ac873197916c13d3c Mon Sep 17 00:00:00 2001 From: Devel Date: Wed, 12 Aug 2026 11:35:19 +0300 Subject: [PATCH 4/4] not every unix has /dev/full --- tests/by-util/test_pathchk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_pathchk.rs b/tests/by-util/test_pathchk.rs index 811bb75a783..d6d7b61bbd0 100644 --- a/tests/by-util/test_pathchk.rs +++ b/tests/by-util/test_pathchk.rs @@ -182,7 +182,7 @@ fn test_pathchk_non_utf8_paths() { } #[test] -#[cfg(unix)] +#[cfg(target_os = "linux")] fn test_not_a_directory_clean() { // https://github.com/uutils/coreutils/issues/13888 new_ucmd!()