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

[PATCH 2/2] pager: set LESS=FRSX also on Windows

From
Johannes Sixt <j6t@kdbg.org>
Date
Sep 11, 2009, 17:45 UTC
Message-ID
<200909111945.07842.j6t@kdbg.org>
In-Reply-To
<200909111940.08652.j6t@kdbg.org>

Previously, this environment variable was set in the pager_preexec callback, which is conditionally-compiled only on Unix, because it is not, and cannot be, called on Windows.

With this patch the env member of struct child_process is used to set the environment variable, which also works on Windows.

Noticed by Alexey Borzenkov.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 Alexey,
 this will result in a conflict when you apply it to your msysgit because
 there is an extra patch that shuffled the setup of pager_process around.
 -- Hannes
 pager.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/pager.c b/pager.c
index 4921843..f416d38 100644
--- a/pager.c
+++ b/pager.c
@@ -21,8 +21,6 @@ static void pager_preexec(void)
 	FD_ZERO(&in);
 	FD_SET(0, &in);
 	select(1, &in, NULL, &in, NULL);
-
-	setenv("LESS", "FRSX", 0);
 }
 #endif
 
@@ -70,6 +68,10 @@ void setup_pager(void)
 	pager_argv[2] = pager;
 	pager_process.argv = pager_argv;
 	pager_process.in = -1;
+	if (!getenv("LESS")) {
+		static const char *env[] = { "LESS=FRSX", NULL };
+		pager_process.env = env;
+	}
 #ifndef __MINGW32__
 	pager_process.preexec_cb = pager_preexec;
 #endif
-- 
1.6.5.rc0.28.gfb9b
Previous: Johannes SixtNext: Junio C Hamano
Message 2 of 3 in “start_command: do not clobber cmd->env on Windows code path”
  1. 1/2 start_command: do not clobber cmd->env on Windows code pathJohannes Sixt, Sep 11, 2009
  2. 2/2 pager: set LESS=FRSX also on WindowsJohannes Sixt, Sep 11, 2009
  3. Junio C HamanoSep 12, 2009

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.