Skip to content

Conversation

nadzyah
Copy link
Member

@nadzyah nadzyah commented Aug 31, 2025

closes #3

@nadzyah nadzyah requested review from slyon, bdrung and lvoytek August 31, 2025 13:04
Copy link
Member

@lvoytek lvoytek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! The implementation here looks good to me overall.
Also for reference here is the version of tail being added to Ubuntu questing - https://github.com/uutils/coreutils/blob/main/src/uu/tail/src/tail.rs

for &byte in buffer[..chunk_size].iter().rev() {
result_bytes.push(byte);

if byte == b'\n' {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to handle the \r\n newline case here too? It's rare to find on Linux but it shows up from time to time


result_bytes.reverse();
let content = String::from_utf8_lossy(&result_bytes);
let mut lines: Vec<String> = content.lines().map(|s| s.to_string()).collect();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fine for most cases, but may differ from GNU coreutils/ UUtils coreutils as they copy over the resulting bytes in the lines directly. I'm fine with it either way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid calling tail command
2 participants