git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Wilhelm Schuermann <wimschuermann@googlemail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH/RFC] grep: fix "--quiet" overwriting current output
Date: Wed, 18 Mar 2015 15:01:08 -0400	[thread overview]
Message-ID: <20150318190107.GB650@peff.net> (raw)
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:

> 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'.

> 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

      reply	other threads:[~2015-03-18 19:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18 18:00 [PATCH/RFC] grep: fix "--quiet" overwriting current output Wilhelm Schuermann
2015-03-18 19:01 ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150318190107.GB650@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=wimschuermann@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).