Re: [RFC] sending errors to stdout under $PAGER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Because we spawn the pager as the foreground process and feed
> its input via pipe from the real command, we cannot affect the
> exit status the shell sees from git command when the pager is in
> use (I think there is not much gain we can have by working it
> around, though).  But at least it may make sense to show the
> error message to the user sitting in front of the pager, perhaps
> like this.
> 
> What do people think?  Have I overlooked any downsides?

I think this is a good idea.

If you are using an interactive pager, you have asked for the content
to come to you through that.  Not unlike how I have chosen to have
the content come to me through a virtual pty and not a printer with
green-and-white bar paper.  :)

I've been bitten by this in the past a few times, but I have also
been knowledgable enough about git, the command I ran, and the
project I ran it on to realize something wasn't right with the
output I am seeing in the pager and retry without the pager to see
the real error(s).

> +++ b/usage.c
> @@ -4,12 +4,15 @@
>   * Copyright (C) Linus Torvalds, 2005
>   */
>  #include "git-compat-util.h"
> +#include "cache.h"
>  
>  static void report(const char *prefix, const char *err, va_list params)
>  {
>  	char msg[256];
> +	FILE *outto = (pager_in_use() ? stdout : stderr);
> +
>  	vsnprintf(msg, sizeof(msg), err, params);
> -	fprintf(stderr, "%s%s\n", prefix, msg);
> +	fprintf(outto, "%s%s\n", prefix, msg);
>  }

-- 
Shawn.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux