test-lib.sh: fix color support when tput needs ~/.terminfo
commitd5c1b7c286b2ad2206afe2f86ae228744bd283fb
authorRichard Hansen <rhansen@bbn.com>
Wed, 17 Jun 2015 21:11:21 +0000 (17 17:11 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Jun 2015 22:16:52 +0000 (17 15:16 -0700)
treed840470a756e517a3ae11ab0cc104c2d4e7ae60c
parentca92a660bf085efd8867861b4d80d95659dd49a3
test-lib.sh: fix color support when tput needs ~/.terminfo

If tput needs ~/.terminfo for the current $TERM, then tput will
succeed before HOME is changed to $TRASH_DIRECTORY (causing color to
be set to 't') but fail afterward.

One possible way to fix this is to treat HOME like TERM: back up the
original value and temporarily restore it before say_color() runs
tput.

Instead, pre-compute and save the color control sequences before
changing either TERM or HOME.  Use the saved control sequences in
say_color() rather than call tput each time.  This avoids the need to
back up and restore the TERM and HOME variables, and it avoids the
overhead of a subshell and two invocations of tput per call to
say_color().

Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh