git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Optimize usage of grep by passing -q

From
MMMikael Magnusson <mikachu@gmail.com>
Date
Nov 17, 2015, 00:59 UTC
Message-ID
<CAHYJk3S-pBQGDk_PPXw5mgzuXhdKqifRB4Vwz1Nu0TecXz4JQg@mail.gmail.com>
In-Reply-To
<1447710209-13117-1-git-send-email-sbeller@google.com>
On Mon, Nov 16, 2015 at 10:43 PM, Stefan Beller <sbeller@google.com> wrote:
Show 9 quoted lines
> Instead of redirecting all grep output to /dev/null, we can just
> pass in -q instead. This preserves the exit code behavior, but is faster.
> As grep returns true if it finds at least one match, grep can exit promptly
> after finding the first line and doesn't need to find more occurrences
> which would be redirected to /dev/null anyways.
>
> This is true for the gnu version of grep. I am not sure if all
> versions of grep support this optimization. In case it is not,
> we'd revert this patch.

POSIX specifies -q, so you should be fine. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html

-- 
Mikael Magnusson
Previous: Stefan BellerNext: Stefan Beller
Message 2 of 4 in “Optimize usage of grep by passing -q”
  1. Optimize usage of grep by passing -qStefan Beller, Nov 16, 2015
  2. Mikael MagnussonNov 17, 2015
  3. Stefan BellerNov 17, 2015
  4. Jeff KingNov 17, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.