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

[PATCH 4/6] Only invoke pager if there's any output

From
Dan Holmsand <holmsand@gmail.com>
Date
Jun 9, 2005, 11:21 UTC
Message-ID
<42A82636.1060505@gmail.com>

This avoids annoying empty "less" window if there's no output from cg-diff, for example.

Signed-off-by: Dan Holmsand <holmsand@gmail.com>
---
 cg-Xlib |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -22,7 +22,11 @@ usage() {
 }
 
 pager () {
-	LESS="R$LESS" ${PAGER:-less} $PAGER_FLAGS
+	# Invoke $PAGER if there is any output
+	local line
+	if read -r line; then
+		( echo "$line"; cat ) | LESS="-R $LESS" ${PAGER:-less}
+	fi
 }
 
 mktemp () {
Message 1 of 1 in “Only invoke pager if there's any output”
  1. 4/6 Only invoke pager if there's any outputDan Holmsand, Jun 9, 2005

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.