{"thread":{"id":"14781","subject":"[PATCH RFC] Do not override LESS","startedAt":"2008-07-31T22:00:44Z","lastAt":"2008-07-31T22:00:44Z","messageCount":1,"participants":["Anders Melchiorsen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"85837","messageId":"1217541644-9297-1-git-send-email-mail@cup.kalibalik.dk","threadId":"14781","inReplyTo":null,"subject":"[PATCH RFC] Do not override LESS","fromName":"Anders Melchiorsen","fromEmail":"mail@cup.kalibalik.dk","sentAt":"2008-07-31T22:00:44Z","receivedAt":"2008-07-31T22:00:44Z","isPatch":true,"sender":{"key":"mail@cup.kalibalik.dk","avatar":null},"body":"Passing options to \"less\" with the LESS environment variable can\ninterfere with existing environment variables. There are at least two\nproblems, as the following examples show:\n\n1. Alice is using git with colors. Now she decides to set LESS=i for\nsome reason. Suddenly, git displays codes in place of colors. Alice\nlikes codes, but she liked colors better!\n\n2. Bob sets GIT_PAGER=\"less -RS\", but does not set LESS. Git sets\nLESS=FRSX before calling $GIT_PAGER. Now Bob wonders why his pager is\nnot always paging, when he explicitly tried to clear the F option.\nMaybe Mallory has been messing with something?\n\nBy passing the options on the command line instead, both of these\nsituations are handled.\n\nSigned-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>\n---\n\nThere are at least two issues with this change:\n\nA. Now /bin/sh will be executed all the time with the default pager. If\nthis is perceived as a performance problem, I can make a special case.\n\nB. This will make existing setups with PAGER=\"less\" behave differently.\nThey can, of course, be fixed with GIT_PAGER=\"less -FRSX\".\n\nI think that neither 1, 2, A or B are big problems. Nevertheless, I think\nthis change makes things \"more correct\", so I hereby offer it for discussion.\n\n\ndiff --git a/pager.c b/pager.c\nindex 6b5c9e4..232d6ed 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -60,7 +60,7 @@ void setup_pager(void)\n \tif (!pager)\n \t\tpager = getenv(\"PAGER\");\n \tif (!pager)\n-\t\tpager = \"less\";\n+\t\tpager = \"less -FRSX\";\n \telse if (!*pager || !strcmp(pager, \"cat\"))\n \t\treturn;\n \n@@ -90,7 +90,6 @@ void setup_pager(void)\n \tclose(fd[0]);\n \tclose(fd[1]);\n \n-\tsetenv(\"LESS\", \"FRSX\", 0);\n \trun_pager(pager);\n \tdie(\"unable to execute pager '%s'\", pager);\n \texit(255);\n-- \n1.5.6.4\n"}]}