diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-05-20 07:28:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-21 07:49:43 +0200 |
commit | 7ad212ff638d38c9b86496a2fffcf7778f1cd4a6 (patch) | |
tree | 2a7e375d93ba1c0b1d68beaaab8a07a25ae2c8dc /Userland | |
parent | daa9812ceac8e6e7200cb93e9d322812883ee2e3 (diff) | |
download | serenity-7ad212ff638d38c9b86496a2fffcf7778f1cd4a6.zip |
tail: Count lines correctly when file ends with two or more newlines
Previously, an extra line would be displayed when a file ended in more
than one newline.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/tail.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index c9ad2abf0b..6ed396c535 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -33,7 +33,7 @@ static ErrorOr<off_t> find_seek_pos(Core::File& file, int wanted_lines) TRY(file.seek(pos - 1, SeekMode::SetPosition)); auto ch = TRY(file.read_value<u8>()); - if (ch == '\n' && (end - pos) > 1) { + if (ch == '\n' && (end - pos) > 0) { lines++; if (lines == wanted_lines) break; |