1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00

lib/bash: make call to tput more robust

Specifically, if `tput colors` fails with an error we treat that as if
the terminal does not support colors.

Fixes #423

Suggested-by: PhotonQuantum <self@lightquantum.me>
This commit is contained in:
Robert Helgesson 2022-10-13 11:11:42 +02:00
parent 8eaa3ba56e
commit 8cbc6500df
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89

View File

@ -23,7 +23,7 @@ function setupColors() {
if [[ ! -v NO_COLOR && -t 1 ]]; then
# See if it supports colors.
local ncolors
ncolors=$(tput colors)
ncolors=$(tput colors 2> /dev/null || echo 0)
if [[ -n "$ncolors" && "$ncolors" -ge 8 ]]; then
normalColor="$(tput sgr0)"