From 7ee73b372126ad091dd9cbfb879415d8e8e62591 Mon Sep 17 00:00:00 2001 From: Sahan Fernando Date: Mon, 14 Jun 2021 23:36:53 +1000 Subject: [PATCH] Userland: Fix double line spacing in grep --- Userland/Utilities/grep.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index 76da12e437..ba3d9bb1d7 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -177,6 +177,8 @@ int main(int argc, char** argv) ScopeGuard free_line = [line] { free(line); }; while ((nread = getline(&line, &line_len, stdin)) != -1) { VERIFY(nread > 0); + if (line[nread - 1] == '\n') + --nread; StringView line_view(line, nread); bool is_binary = line_view.contains(0);