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

Re: [PATCH/RFC] grep: fix "--quiet" overwriting current output

From
Jeff King <peff@peff.net>
Date
Mar 18, 2015, 19:01 UTC
Message-ID
<20150318190107.GB650@peff.net>
In-Reply-To
<1426701613-12533-1-git-send-email-wimschuermann@googlemail.com>
On Wed, Mar 18, 2015 at 07:00:13PM +0100, Wilhelm Schuermann wrote:
Show 6 quoted lines
> When grep is called with the --quiet option, the pager is initialized
> despite not being used.  When the pager is "less", anything output by
> previous commands and not ended with a newline is overwritten.
> [...]
> This patch prevents calling the pager in the first place, saving an
> unnecessary fork() call.

Thanks, I think this makes sense. We do a similar thing for "git diff --quiet". If you do not set "-F" in your $LESS variable, it is even more annoying. E.g., with:

  if git grep -q foo; then
    : do something
  fi
which will pause, waiting for the user to hit 'q'.
Show 11 quoted lines
> diff --git a/builtin/grep.c b/builtin/grep.c
> index e77f7cf..fe7b9fd 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -885,7 +885,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>  		}
>  	}
>  
> -	if (!show_in_pager)
> +	if (!show_in_pager && !opt.status_only)
>  		setup_pager();
Patch looks obviously correct.
-Peff
Previous: Wilhelm Schuermann
Message 2 of 2 in “grep: fix "--quiet" overwriting current output”
  1. grep: fix "--quiet" overwriting current outputWilhelm Schuermann, Mar 18, 2015
  2. Jeff KingMar 18, 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.