pager: move pager-specific setup into the build

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>
This commit is contained in:
Eric Wong
2016-08-04 11:40:25 +00:00
committed by Junio C Hamano
parent 08df31eecc
commit 995bc22d7f
5 changed files with 67 additions and 8 deletions

View File

@@ -160,9 +160,11 @@ git_pager() {
else
GIT_PAGER=cat
fi
: "${LESS=-FRX}"
: "${LV=-c}"
export LESS LV
for vardef in @@PAGER_ENV@@
do
var=${vardef%%=*}
eval ": \"\${$vardef}\" && export $var"
done
eval "$GIT_PAGER" '"$@"'
}