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

[PATCH RESEND] Do not override LESS

From
AMAnders Melchiorsen <mail@cup.kalibalik.dk>
Date
Aug 22, 2008, 12:25 UTC
Message-ID
<1219407912-32085-1-git-send-email-mail@cup.kalibalik.dk>

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
Next: Junio C Hamano
Message 1 of 8 in “Do not override LESS”
  1. Do not override LESSAnders Melchiorsen, Aug 22, 2008
  2. Junio C HamanoAug 23, 2008
  3. Anders MelchiorsenAug 23, 2008
  4. Junio C HamanoAug 23, 2008
  5. Anders MelchiorsenAug 23, 2008
  6. Jonathan NiederAug 24, 2008
  7. Documentation: clarify pager.<cmd> configurationJonathan Nieder, Aug 24, 2008
  8. Junio C HamanoAug 24, 2008

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.