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

From: Dan Holmsand <holmsand@gmail.com>
Date: 2005-06-09 21:21:26
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 () {


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Jun 09 22:23:43 2005

This archive was generated by hypermail 2.1.8 : 2005-06-09 22:23:44 EST