1. That script's color check doesn't check that the output is a terminal. Also test
tty -s
export STDOUT_COLOR_START="`tput setaf 4`".