1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-19 16:29:47 +01: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 if [[ ! -v NO_COLOR && -t 1 ]]; then
# See if it supports colors. # See if it supports colors.
local ncolors local ncolors
ncolors=$(tput colors) ncolors=$(tput colors 2> /dev/null || echo 0)
if [[ -n "$ncolors" && "$ncolors" -ge 8 ]]; then if [[ -n "$ncolors" && "$ncolors" -ge 8 ]]; then
normalColor="$(tput sgr0)" normalColor="$(tput sgr0)"