From 2deca89cf0c7a99450f88cf0abfadd336511633f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 16 May 2022 12:18:26 -0700 Subject: [PATCH] grep: document -m better * doc/grep.in.1, doc/grep.texi: Document behavior of -m 0 and -m -1. This documents longstanding behavior, and is consistent with how git grep -m will likely behave. --- doc/grep.in.1 | 10 ++++++++++ doc/grep.texi | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/doc/grep.in.1 b/doc/grep.in.1 index aba085a..5ba90ee 100644 --- a/doc/grep.in.1 +++ b/doc/grep.in.1 @@ -321,6 +321,16 @@ Scanning each input file stops upon first match. Stop reading a file after .I NUM matching lines. +If +.I NUM +is zero, +.B grep +stops right away without reading input. +A +.I NUM +of \-1 is treated as infinity and +.B grep +does not stop; this is the default. If the input is standard input from a regular file, and .I NUM diff --git a/doc/grep.texi b/doc/grep.texi index b9688c8..b073fa7 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -341,6 +341,10 @@ Scanning each input file stops upon first match. @opindex --max-count @cindex max-count Stop after the first @var{num} selected lines. +If @var{num} is zero, @command{grep} stops right away without reading input. +A @var{num} of @minus{}1 is treated as infinity and @command{grep} +does not stop; this is the default. + If the input is standard input from a regular file, and @var{num} selected lines are output, @command{grep} ensures that the standard input is positioned -- 2.34.1