[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: [PATCH RFC] Do not override LESS
From: Anders Melchiorsen <mail () cup ! kalibalik ! dk>
Date: 2008-07-31 22:00:44
Message-ID: 1217541644-9297-1-git-send-email-mail () cup ! kalibalik ! dk
[Download RAW message or body]
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, git displays codes in place of colors. Alice
likes codes, but she liked colors better!
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.
Maybe Mallory has been messing with something?
By passing the options on the command line instead, both of these
situations are handled.
Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
---
There are at least two issues with this change:
A. Now /bin/sh will be executed all the time with the default pager. If
this is perceived as a performance problem, I can make a special case.
B. This will make existing setups with PAGER="less" behave differently.
They can, of course, be fixed with GIT_PAGER="less -FRSX".
I think that neither 1, 2, A or B are big problems. Nevertheless, I think
this change makes things "more correct", so I hereby offer it for discussion.
diff --git a/pager.c b/pager.c
index 6b5c9e4..232d6ed 100644
--- a/pager.c
+++ b/pager.c
@@ -60,7 +60,7 @@ void setup_pager(void)
if (!pager)
pager = getenv("PAGER");
if (!pager)
- pager = "less";
+ pager = "less -FRSX";
else if (!*pager || !strcmp(pager, "cat"))
return;
@@ -90,7 +90,6 @@ void setup_pager(void)
close(fd[0]);
close(fd[1]);
- setenv("LESS", "FRSX", 0);
run_pager(pager);
die("unable to execute pager '%s'", pager);
exit(255);
--
1.5.6.4
--
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic