Skip to content

Commit

Permalink
Possibly catch any tput errors?
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranahmedse committed Apr 26, 2016
1 parent 67b05f7 commit 92fe3f5
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions git-standup
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,38 @@ 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=""
BLUE=""
BOLD=""
UNDERLINE=""
NORMAL=""
fi
}


# Only enable exit-on-error after the non-critical colorization stuff,
Expand Down

0 comments on commit 92fe3f5

Please sign in to comment.