diff --git a/bin/email-via-mailgun-smtp b/bin/email-via-mailgun-smtp index 3b885cf..2b2dfb5 100755 --- a/bin/email-via-mailgun-smtp +++ b/bin/email-via-mailgun-smtp @@ -1,11 +1,29 @@ #!/usr/bin/env bash err() { - >&2 echo "ERROR: $@"; usage; exit 1 + errpre="" + errpost="" + if test -t 1; then + ncolors=$(tput colors) + if test -n "$ncolors" && test $ncolors -ge 8; then + errpre="$(tput setaf 1)" + errpost="$(tput setaf 7)" + fi + fi + >&2 echo "${errpre}ERROR: $@${errpost}"; usage; exit 1 } warn() { - >&2 echo "$@" + pre="" + post="" + if test -t 1; then + ncolors=$(tput colors) + if test -n "$ncolors" && test $ncolors -ge 8; then + pre="$(tput setaf 3)" + post="$(tput setaf 7)" + fi + fi + >&2 echo "${pre}WARNING: $@${post}" } usage() { >&2 cat <&2 echo "Finished reading body. Sending email..." swaks --auth \ --server smtp.mailgun.org \