git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/6] Only invoke pager if there's any output
@ 2005-06-09 11:21 Dan Holmsand
  0 siblings, 0 replies; only message in thread
From: Dan Holmsand @ 2005-06-09 11:21 UTC (permalink / raw)
  To: git; +Cc: Petr Baudis

[-- Attachment #1: Type: text/plain, Size: 144 bytes --]

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

Signed-off-by: Dan Holmsand <holmsand@gmail.com>
---


[-- Attachment #2: 4-pager.patch.txt --]
[-- Type: text/plain, Size: 382 bytes --]

 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 () {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-06-09 12:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-09 11:21 [PATCH 4/6] Only invoke pager if there's any output Dan Holmsand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).