[llvm/Support] Fallback to $TERM if terminfo has no "colors" capability
authorMed Ismail Bennani <medismail.bennani@gmail.com>
Wed, 18 May 2022 18:33:31 +0000 (11:33 -0700)
committerMed Ismail Bennani <medismail.bennani@gmail.com>
Thu, 19 May 2022 01:22:46 +0000 (18:22 -0700)
commitb3718bc4672bcad45f155c6d2f9fce4ad409bb8e
tree46e7b211db0174061a6e88913186c4b7ae8b9a4a
parenta5d618b393fe5027c0788fdb20b79d2d84c61067
[llvm/Support] Fallback to $TERM if terminfo has no "colors" capability

It can happen on macOS that terminal doesn't report the "colors"
capability in the terminfo database, in which case `tigetnum` returns -1.

This doesn't mean however that the terminal doesn't supports color, it
just means that the capability is absent from the terminal description.

In that case, we should still fallback to the checking the $TERM
environment variable to see if it supports ANSI escapes codes.

Differential Revision: https://reviews.llvm.org/D125914

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
llvm/lib/Support/Unix/Process.inc