From 24a556b8b763f0ed437afd0fc2c5b52426bd5bf5 Mon Sep 17 00:00:00 2001 From: Martin Kunkel Date: Thu, 29 May 2025 23:13:54 +0200 Subject: [PATCH] tail: show end of device gnu coreutils will show end of device for block devices. In current implementation this is skipped as a block devices are recognized as untailable. The change ensures that we first try to output the end of any file and only then tell the observer that the file is not observable. --- src/uu/tail/src/tail.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/uu/tail/src/tail.rs b/src/uu/tail/src/tail.rs index c8946d98c1e..a089d210b7a 100644 --- a/src/uu/tail/src/tail.rs +++ b/src/uu/tail/src/tail.rs @@ -177,7 +177,7 @@ fn tail_file( return Ok(()); } observer.add_bad_path(path, input.display_name.as_str(), false)?; - } else if input.is_tailable() { + } else { match File::open(path) { Ok(mut file) => { let st = file.metadata()?; @@ -194,12 +194,16 @@ fn tail_file( reader = BufReader::new(file); unbounded_tail(&mut reader, settings)?; } - observer.add_path( - path, - input.display_name.as_str(), - Some(Box::new(reader)), - true, - )?; + if input.is_tailable() { + observer.add_path( + path, + input.display_name.as_str(), + Some(Box::new(reader)), + true, + )?; + } else { + observer.add_bad_path(path, input.display_name.as_str(), false)?; + } } Err(e) if e.kind() == ErrorKind::PermissionDenied => { observer.add_bad_path(path, input.display_name.as_str(), false)?; @@ -220,8 +224,6 @@ fn tail_file( })); } } - } else { - observer.add_bad_path(path, input.display_name.as_str(), false)?; } Ok(())