4 * This is split up from the rest of git so that we might do
5 * something different on Windows, for example.
9 static void run_pager(const char *pager
)
12 * Work around bug in "less" by not starting it until we
19 select(1, &in
, NULL
, &in
, NULL
);
21 execlp(pager
, pager
, NULL
);
22 execl("/bin/sh", "sh", "-c", pager
, NULL
);
25 #include "run-command.h"
27 const char *pager_argv
[] = { "sh", "-c", NULL
, NULL
};
28 static struct child_process pager_process
= {
32 static void collect_pager(void)
35 close(1); /* signals EOF to pager */
36 finish_command(&pager_process
);
40 void setup_pager(void)
46 const char *pager
= getenv("GIT_PAGER");
52 git_config(git_default_config
);
53 pager
= pager_program
;
56 pager
= getenv("PAGER");
59 else if (!*pager
|| !strcmp(pager
, "cat"))
62 pager_in_use
= 1; /* means we are emitting to terminal */
74 /* return in the child */
82 /* The original process turns into the PAGER */
87 setenv("LESS", "FRSX", 0);
89 die("unable to execute pager '%s'", pager
);
93 pager_argv
[2] = pager
;
94 if (start_command(&pager_process
))
97 /* original process continues, but writes to the pipe */
98 dup2(pager_process
.in
, 1);
99 close(pager_process
.in
);
101 /* this makes sure that the parent terminates after the pager */
102 atexit(collect_pager
);