threads / patch / 880

patch, 6 partsOnly invoke pager if there's any output

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

## tl;dr

One message between Jun 9, 2005 and Jun 9, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Dan Holmsand· Jun 9, 2005, 11:21 UTC · lore

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(-)
Show changes to cg-Xlib +5 −1
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 () {

← back to recent threads