summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr-paiva <rui.paiva.10@hotmail.com>2021-04-29 16:07:17 +0100
committerAndreas Kling <kling@serenityos.org>2021-05-20 23:53:06 +0200
commit68de9008e753ad577e00da5f035b98a4d51512ec (patch)
treef49b57f8e4a47f52d3837de061ef32ffb51fe0d5
parenteed0bcaf420c6250e767d6ef8da12736021e3f06 (diff)
downloadserenity-68de9008e753ad577e00da5f035b98a4d51512ec.zip
Utilities: Fix grep match when reading from stdin
When reading from stdin, grep discards the last character, even if that character is not \n. This commit changes grep to no longer discard the last character from a line.
-rw-r--r--Userland/Utilities/grep.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp
index a2483650bc..a7eef6c56d 100644
--- a/Userland/Utilities/grep.cpp
+++ b/Userland/Utilities/grep.cpp
@@ -177,7 +177,7 @@ int main(int argc, char** argv)
ScopeGuard free_line = [line] { free(line); };
while ((nread = getline(&line, &line_len, stdin)) != -1) {
VERIFY(nread > 0);
- StringView line_view(line, nread - 1);
+ StringView line_view(line, nread);
bool is_binary = line_view.contains(0);
if (is_binary && binary_mode == BinaryFileMode::Skip)