From ccd3859ceb5622294f2a4b61524974a0c1ee22f7 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Tue, 22 Jul 2008 13:42:58 +0200 Subject: [PATCH] Windows: Better support PAGER settings with spaces in the path On Windows, the pager was always run via a shell, which is not the case on Unix, where the shell variant was only used as a fallback. Thus, setting the pager, for example, like this: PAGER="C:/Program Files/msys/bin/less" would fail; an extra set of quotes is needed: PAGER="\"C:/Program Files/msys/bin/less\"" With this patch the former setting works as well. Signed-off-by: Johannes Sixt --- pager.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pager.c b/pager.c index 4921843577..77e9dd6ae4 100644 --- a/pager.c +++ b/pager.c @@ -9,7 +9,6 @@ static int spawned_pager; -#ifndef __MINGW32__ static void pager_preexec(void) { /* @@ -24,7 +23,6 @@ static void pager_preexec(void) setenv("LESS", "FRSX", 0); } -#endif static const char *pager_argv[] = { "sh", "-c", NULL, NULL }; static struct child_process pager_process; @@ -68,13 +66,15 @@ void setup_pager(void) /* spawn the pager */ pager_argv[2] = pager; - pager_process.argv = pager_argv; - pager_process.in = -1; -#ifndef __MINGW32__ pager_process.preexec_cb = pager_preexec; -#endif - if (start_command(&pager_process)) - return; + pager_process.argv = &pager_argv[2]; + pager_process.in = -1; + if (start_command(&pager_process)) { + pager_process.argv = pager_argv; + pager_process.in = -1; + if (start_command(&pager_process)) + return; + } /* original process continues, but writes to the pipe */ dup2(pager_process.in, 1);