git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] Do not override LESS
@ 2008-08-22 12:25 Anders Melchiorsen
  2008-08-23  5:35 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Anders Melchiorsen @ 2008-08-22 12:25 UTC (permalink / raw)
  To: git; +Cc: gitster, Anders Melchiorsen

Passing options to "less" with the LESS environment variable can
interfere with existing environment variables. There are at least two
problems, as the following examples show:

1. Alice is using git with colors. Now she decides to set LESS=i for
some reason. Suddenly, she sees codes in place of colors because LESS
is no longer set automatically.

2. Bob sets GIT_PAGER="less -RS", but does not set LESS. Git sets
LESS=FRSX before calling $GIT_PAGER. Now Bob wonders why his pager is
not always paging, when he explicitly tried to clear the F option.

By passing the options on the command line instead, both of these
situations are handled.

Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
---


Here is a resend, as I got no comments on the first try. The patch
is rebased to the recent pager-swap setup.

For completeness, I note that this change will make existing setups
with PAGER="less" behave differently, as they will no longer have
-FRSX options set automatically. I tend to think that this is correct,
since you then get what you ask for.


 pager.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/pager.c b/pager.c
index aa0966c..9753fe9 100644
--- a/pager.c
+++ b/pager.c
@@ -20,8 +20,6 @@ static void pager_preexec(void)
 	FD_ZERO(&in);
 	FD_SET(0, &in);
 	select(1, &in, NULL, &in, NULL);
-
-	setenv("LESS", "FRSX", 0);
 }
 #endif
 
@@ -52,7 +50,7 @@ void setup_pager(void)
 	if (!pager)
 		pager = getenv("PAGER");
 	if (!pager)
-		pager = "less";
+		pager = "less -FRSX";
 	else if (!*pager || !strcmp(pager, "cat"))
 		return;
 
-- 
1.5.6.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-08-24 19:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-22 12:25 [PATCH RESEND] Do not override LESS Anders Melchiorsen
2008-08-23  5:35 ` Junio C Hamano
2008-08-23  8:28   ` Anders Melchiorsen
2008-08-23  9:08     ` Junio C Hamano
2008-08-23 10:21       ` Anders Melchiorsen
2008-08-24  5:28     ` Jonathan Nieder
2008-08-24  5:38       ` [PATCH] Documentation: clarify pager.<cmd> configuration Jonathan Nieder
2008-08-24 18:59       ` [PATCH RESEND] Do not override LESS Junio C Hamano

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).