pager: set LESS=FRSX also on Windows
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Sep 11, 2009 at 19:45 UTC
25fc1786ab147daa9ffa43ebcbaf5c1cc6e50d4f
1 file changed
+4
-2
pager.c
+4
-2
@@ -21,8 +21,6 @@ static void pager_preexec(void)
21
FD_ZERO(&in);
22
FD_SET(0, &in);
23
select(1, &in, NULL, &in, NULL);
24
-
25
- setenv("LESS", "FRSX", 0);
24
}
25
#endif
26
@@ -70,6 +68,10 @@ void setup_pager(void)
68
pager_argv[2] = pager;
69
pager_process.argv = pager_argv;
70
pager_process.in = -1;
71
+ if (!getenv("LESS")) {
72
+ static const char *env[] = { "LESS=FRSX", NULL };
73
+ pager_process.env = env;
74
+ }
75
#ifndef __MINGW32__
76
pager_process.preexec_cb = pager_preexec;
77
#endif