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

Re: [PATCH] Don't ignore write failure from git-diff, git-log, etc.

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 27, 2007, 16:17 UTC
Message-ID
<alpine.LFD.0.98.0705270904240.26602@woody.linux-foundation.org>
In-Reply-To
<87odk6y6cd.fsf@rho.meyering.net>
On Sun, 27 May 2007, Jim Meyering wrote:
> 
> I have to disagree.  There may be precedent for hiding EPIPE errors,
> but that is not the norm among command line tools wrt piped stdout.

.. and this is a PROBLEM. Which is why I think your patch was really wrong.

I don't know how many people remember all the _stupid_ problems we had exactly because many versions of bash are crap, crap, crap, and people (including you) don't realize that EPIPE is _different_ from other write errors.

Just do a google search for
	"broken pipe" bash

and not only will you see a lot of complaints, but the #5 entry is a complaint for a git issue that we had tons of problems with. See for example

	http://www.gelato.unsw.edu.au/archives/git/0504/2602.html

The reason? Some _idiotic_ versions of bash don't have DONT_REPORT_SIGPIPE on by default.

So I do get upset when people then make the same error with git.
Show 10 quoted lines
> Do you really want git-log to continue to do this?
> 
>     $ (trap '' PIPE; git-log; echo $? >&2 ) | :
>     0
> 
> With my patch, it does this:
> 
>     $ (trap '' PIPE; ./git-log; echo $? >&2 ) | :
>     fatal: write failure on standard output: Broken pipe
>     128
That error return is fine. The annoying error report, however, is NOT.

For _exactly_ the same reason that a bash that doesn't have DONT_REPORT_SIGPIPE enabled is a piece of crap.

And your arguments that "others do it wrong, so we can too" is so broken as to be really really sad. If you cannot see the serious problem with that argument, I don't know what to tell you.

Try this:
	trap '' PIPE; ./git-log | head
and dammit, if you get an error message from that, your program is BROKEN.
And if you cannot understand that, then I don't even know what to say.

But _exiting_ is fine. It's the bogus error reporting that isn't. The above command like should NOT cause the user to have to skip stderr - because no error happened!

(Whether the error code is 0 or some error, I dunno. I'd argue that if you ignore SIGPIPE, you'd probably also want to do "exit(0)" for EPIPE, but it's not nearly as annoying as writing bogus error messages to stderr.

			Linus
Previous: Jim MeyeringNext: Jim Meyering
Message 6 of 29 in “Don't ignore write failure from git-diff, git-log, etc.”
  1. Don't ignore write failure from git-diff, git-log, etc.Jim Meyering, May 26, 2007
  2. Linus TorvaldsMay 26, 2007
  3. Junio C HamanoMay 26, 2007
  4. Nicolas PitreMay 27, 2007
  5. Jim MeyeringMay 27, 2007
  6. Linus TorvaldsMay 27, 2007
  7. Jim MeyeringMay 28, 2007
  8. Marco RoelandMay 28, 2007
  9. Jim MeyeringMay 28, 2007
  10. Marco RoelandMay 28, 2007
  11. Jim MeyeringMay 28, 2007
  12. Petr BaudisMay 28, 2007
  13. Junio C HamanoMay 28, 2007
  14. Jim MeyeringMay 29, 2007
  15. Junio C HamanoMay 29, 2007
  16. Jim MeyeringMay 30, 2007
  17. Linus TorvaldsMay 28, 2007
  18. Jim MeyeringMay 28, 2007
  19. Linus TorvaldsMay 29, 2007
  20. Jim MeyeringMay 29, 2007
  21. Linus TorvaldsMay 29, 2007
  22. Jim MeyeringMay 30, 2007
  23. Linus TorvaldsMay 30, 2007
  24. Jim MeyeringMay 30, 2007
  25. Junio C HamanoMay 28, 2007
  26. Linus TorvaldsMay 29, 2007
  27. Jim MeyeringMay 30, 2007
  28. Junio C HamanoMay 30, 2007
  29. Jim MeyeringMay 30, 2007

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.