diff options
author | Eric Wong <e@80x24.org> | 2016-08-04 11:40:25 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-08-04 13:51:02 -0700 |
commit | 995bc22d7f8c611e342095a211065f8585a08e65 (patch) | |
tree | b4f244806f75de3be427bff1411112a4f4bf1c39 /pager.c | |
parent | 08df31eeccfe1576971ea4ba42570a424c3cfc41 (diff) | |
download | git-995bc22d7f8c611e342095a211065f8585a08e65.tar.gz |
pager: move pager-specific setup into the buildew/build-time-pager-tweaks
Allowing PAGER_ENV to be set at build-time allows us to move
pager-specific knowledge out of our build. This allows us to
set a better default for FreeBSD more(1), which pretends not to
understand ANSI color escapes if the MORE environment variable
is left empty, but accepts the same variables as less(1)
Originally-from:
https://public-inbox.org/git/xmqq61piw4yf.fsf@gitster.dls.corp.google.com/
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pager.c')
-rw-r--r-- | pager.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -63,14 +63,38 @@ const char *git_pager(int stdout_is_tty) return pager; } +static void setup_pager_env(struct argv_array *env) +{ + const char **argv; + int i; + char *pager_env = xstrdup(PAGER_ENV); + int n = split_cmdline(pager_env, &argv); + + if (n < 0) + die("malformed build-time PAGER_ENV: %s", + split_cmdline_strerror(n)); + + for (i = 0; i < n; i++) { + char *cp = strchr(argv[i], '='); + + if (!cp) + die("malformed build-time PAGER_ENV"); + + *cp = '\0'; + if (!getenv(argv[i])) { + *cp = '='; + argv_array_push(env, argv[i]); + } + } + free(pager_env); + free(argv); +} + void prepare_pager_args(struct child_process *pager_process, const char *pager) { argv_array_push(&pager_process->args, pager); pager_process->use_shell = 1; - if (!getenv("LESS")) - argv_array_push(&pager_process->env_array, "LESS=FRX"); - if (!getenv("LV")) - argv_array_push(&pager_process->env_array, "LV=-c"); + setup_pager_env(&pager_process->env_array); } void setup_pager(void) |