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@xxxxxxxxxxxxxxxx> --- 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@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html