Skip to content

Commit

Permalink
lib/bash: make call to tput more robust
Browse files Browse the repository at this point in the history
Specifically, if `tput colors` fails with an error we treat that as if
the terminal does not support colors.

Fixes nix-community#423

Suggested-by: PhotonQuantum <[email protected]>
  • Loading branch information
rycee committed Oct 13, 2022
1 parent 8eaa3ba commit 8cbc650
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bash/home-manager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

0 comments on commit 8cbc650

Please sign in to comment.