From 92fe3f5a32f906f2842c59940f75a718db090868 Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Tue, 26 Apr 2016 08:18:34 +0400 Subject: [PATCH] Possibly catch any tput errors? --- git-standup | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/git-standup b/git-standup index a149240..25793af 100755 --- a/git-standup +++ b/git-standup @@ -12,21 +12,30 @@ if [[ ! $option_a ]] && [[ ! $option_d ]] && [[ ! $option_w ]] && [[ $# -gt 0 ] exit 1 fi - -# Use colors, but only if connected to a terminal, and that terminal -# supports them. -if which tput >/dev/null 2>&1; then - ncolors=$(tput colors) -fi -if [[ -t 1 ]] && [[ -n "$ncolors" ]] && [[ "$ncolors" -ge 8 ]] ; then - RED=$(tput setaf 1) - GREEN=$(tput setaf 2) - YELLOW=$(tput setaf 3) - BLUE=$(tput setaf 4) - BOLD=$(tput bold) - UNDERLINE=$(tput smul) - NORMAL=$(tput sgr0) -else +{ + # Use colors, but only if connected to a terminal, and that terminal + # supports them. + if which tput >/dev/null 2>&1; then + ncolors=$(tput colors) + fi + if [[ -t 1 ]] && [[ -n "$ncolors" ]] && [[ "$ncolors" -ge 8 ]] ; then + RED=$(tput setaf 1) + GREEN=$(tput setaf 2) + YELLOW=$(tput setaf 3) + BLUE=$(tput setaf 4) + BOLD=$(tput bold) + UNDERLINE=$(tput smul) + NORMAL=$(tput sgr0) + else + RED="" + GREEN="" + YELLOW="" + BLUE="" + BOLD="" + UNDERLINE="" + NORMAL="" + fi +} || { RED="" GREEN="" YELLOW="" @@ -34,7 +43,7 @@ else BOLD="" UNDERLINE="" NORMAL="" -fi +} # Only enable exit-on-error after the non-critical colorization stuff,