summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTim Ledbetter <timledbetter@gmail.com>2023-05-20 07:28:30 +0100
committerAndreas Kling <kling@serenityos.org>2023-05-21 07:49:43 +0200
commit7ad212ff638d38c9b86496a2fffcf7778f1cd4a6 (patch)
tree2a7e375d93ba1c0b1d68beaaab8a07a25ae2c8dc /Userland
parentdaa9812ceac8e6e7200cb93e9d322812883ee2e3 (diff)
downloadserenity-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.cpp2
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;