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

Re: fatal output from git-show really wants a terminal

From
Jeff King <peff@peff.net>
Date
Dec 11, 2008, 21:55 UTC
Message-ID
<20081211215554.GA11565@sigill.intra.peff.net>
In-Reply-To
<200812111051.20322.bss03@volumehost.net>
On Thu, Dec 11, 2008 at 10:51:15AM -0600, Boyd Stephen Smith Jr. wrote:
> Initially, I was looking for 'stdout' or 'stderr', and found many unrelated 
> commits.  I then figured it was part of the PAGER support, and began 

Try looking for isatty, which takes the numeric fd. I think the behavior you asked about would be this:

diff --git a/pager.c b/pager.c
index aa0966c..19f8856 100644
--- a/pager.c
+++ b/pager.c
@@ -42,7 +42,7 @@ void setup_pager(void)
 {
 	const char *pager = getenv("GIT_PAGER");
 
-	if (!isatty(1))
+	if (!isatty(0) || !isatty(2))
 		return;
 	if (!pager) {
 		if (!pager_program)

which is what is mentioned in POSIX:

  http://www.opengroup.org/onlinepubs/009695399/utilities/sh.html

But I don't think that makes sense here. We are not talking about
interactivity, but rather about where the output is going. So your test
would consider this interactive:

  $ git log >foo.out

and start a pager, which makes no sense.

Now if you proposed checking stderr and stdin _in addition_ to stdout,
that might make more sense, but I haven't thought too hard about any
implications.

And FWIW, I don't recall this ever being discussed before, but then I
have not been involved with git since the very beginning.

-Peff
Previous: Boyd Stephen Smith Jr.Next: Boyd Stephen Smith Jr.
Message 7 of 13 in “fatal output from git-show really wants a terminal”
  1. Tim OlsenDec 10, 2008
  2. Boyd Stephen Smith Jr.Dec 10, 2008
  3. Johannes SixtDec 10, 2008
  4. Tim OlsenDec 10, 2008
  5. Boyd Stephen Smith Jr.Dec 10, 2008
  6. Boyd Stephen Smith Jr.Dec 11, 2008
  7. Jeff KingDec 11, 2008
  8. Boyd Stephen Smith Jr.Dec 11, 2008
  9. Jeff KingDec 11, 2008
  10. Junio C HamanoDec 11, 2008
  11. Junio C HamanoDec 15, 2008
  12. Junio C HamanoDec 15, 2008
  13. Jeff KingDec 15, 2008

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.