From 96321f958cfed1a8bbe01f9e8268265fe436ade5 Mon Sep 17 00:00:00 2001 From: Joining7943 <111500881+Joining7943@users.noreply.github.com> Date: Sun, 18 Sep 2022 17:00:43 +0200 Subject: [PATCH] tail: Fix random errors mainly on macos for piped input. Treat resolved paths to /dev/fd/0 as pipe. Closes #3953 --- src/uu/tail/src/paths.rs | 5 ++++- src/uu/tail/src/text.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uu/tail/src/paths.rs b/src/uu/tail/src/paths.rs index 0ebb265b2..203a23817 100644 --- a/src/uu/tail/src/paths.rs +++ b/src/uu/tail/src/paths.rs @@ -75,7 +75,10 @@ impl Input { } InputKind::File(_) | InputKind::Stdin => { if cfg!(unix) { - PathBuf::from(text::DEV_STDIN).canonicalize().ok() + match PathBuf::from(text::DEV_STDIN).canonicalize().ok() { + Some(path) if path != PathBuf::from(text::FD0) => Some(path), + Some(_) | None => None, + } } else { None } diff --git a/src/uu/tail/src/text.rs b/src/uu/tail/src/text.rs index fba3968dd..62ad9cf70 100644 --- a/src/uu/tail/src/text.rs +++ b/src/uu/tail/src/text.rs @@ -18,3 +18,4 @@ pub static BACKEND: &str = "inotify"; pub static BACKEND: &str = "kqueue"; #[cfg(target_os = "windows")] pub static BACKEND: &str = "ReadDirectoryChanges"; +pub static FD0: &str = "/dev/fd/0";