Skip to content

Commit 5c0d062

Browse files
kusmaj6t
authored andcommitted
test-lib: add support for colors without tput
For platforms that does not have tput we can still perform coloring by manually emitting the ANSI control codes. If tput is missing from $PATH, install a replacement function. The exact strings has been dumped from a machine that has tput, by piping the output of tput through 'od -c -An'. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
1 parent d0ce57c commit 5c0d062

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

t/test-lib.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,20 @@ u200c=$(printf '\342\200\214')
598598

599599
export _x05 _x35 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX
600600

601+
if ! command -v tput >/dev/null
602+
then
603+
tput () {
604+
case "$1" in
605+
bold)
606+
printf "\033[1m" ;;
607+
setaf)
608+
printf "\033[0;3$2m" ;;
609+
sgr0)
610+
printf "\033(\033[m" ;;
611+
esac
612+
}
613+
fi
614+
601615
test "x$TERM" != "xdumb" && (
602616
test -t 1 &&
603617
tput bold >/dev/null 2>&1 &&

0 commit comments

Comments
 (0)