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

Re: [PATCH] pager: die when paging to non-existing command

From
Jeff King <peff@peff.net>
Date
Jun 21, 2024, 06:51 UTC
Message-ID
<20240621065127.GC2105230@coredump.intra.peff.net>
In-Reply-To
<xmqqplsbqm2l.fsf@gitster.g>
On Thu, Jun 20, 2024 at 03:35:46PM -0700, Junio C Hamano wrote:
Show 22 quoted lines
> Johannes Sixt <j6t@kdbg.org> writes:
> 
> > Am 20.06.24 um 21:04 schrieb Junio C Hamano:
> >> Just in case there is a reason why we should instead silently return
> >> on MinGW, I'll Cc the author of bfdd9ffd, though.
> >
> > I don't think there is a reason. IIRC, originally on Windows, failing to
> > start a pager would still let Git operate normally, just without paged
> > output. I might have regarded this as better than to fail the operation.
> 
> The "better keep going than to fail" is what Rubén finds worse, so
> both sides are quite understandable.
> 
> It is unlikely that real-world users are taking advantage of the
> fact.  If they do not want their invocation of Git command paged,
> "GIT_PAGER=cat git foo" is just as easy as "GIT_PAGER=no git foo",
> and if it was done by mistake to configure a non-working pager
> (e.g., configure core.pager to the program xyzzy and then
> uninstalling xyzzy without realizing you still have users), fixing
> it would be a one-time operation either way (you update core.pager
> or you reinstall xyzzy), so I would say that it is better to make
> the failure more stand out.

The compelling thing to me is that just about every other failure mode of the pager will result in a SIGPIPE, so the "be nice with a non-working pager" trick really only applies to the very narrow case of execve() failing.

I did assume that a bogus option like:
  # oops, there is no -l option!
  GIT_PAGER='less -l' git log

would be a plausible such misconfiguration, but to my surprise "less" prints "hey, there is no -l option" and then pages anyway. How helpful. :)

But something like:
  # oops, there is no -X option!
  GIT_PAGER='cat -X' git log
yields just:
  cat: invalid option -- 'X'
  Try 'cat --help' for more information.

with no other output. It's a little confusing if you don't realize that "cat" is the pager. We obviously don't want to complain about SIGPIPE, because it's common for the user to simply exit the pager without reading all of the possible data. It might be nice if we printed some message when the pager exits non-zero, but I'd worry there might be false positives, depending on the behavior of various pagers.

-Peff
Previous: Junio C HamanoNext: Dragan Simic
Message 7 of 17 in “pager: die when paging to non-existing command”
  1. pager: die when paging to non-existing commandRubén Justo, Jun 20, 2024
  2. Junio C HamanoJun 20, 2024
  3. Rubén JustoJun 20, 2024
  4. Junio C HamanoJun 20, 2024
  5. Johannes SixtJun 20, 2024
  6. Junio C HamanoJun 20, 2024
  7. Jeff KingJun 21, 2024
  8. Dragan SimicJun 21, 2024
  9. Johannes SchindelinJun 24, 2024
  10. Phillip WoodJun 21, 2024
  11. Junio C HamanoJun 21, 2024
  12. Jeff KingJun 21, 2024
  13. Rubén JustoJun 21, 2024
  14. pager: die when paging to non-existing commandRubén Justo, Jun 21, 2024
  15. pager: die when paging to non-existing commandRubén Justo, Jun 21, 2024
  16. Johannes SixtJun 22, 2024
  17. pager: die when paging to non-existing commandRubén Justo, Jun 23, 2024

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.