I pulled an example from this question to create the following example:
#!/bin/bash
export GREEN='\033[0;32m'
export RED='\033[0;31m'
export NC='\033[0m' # No Color
echo "I ${RED}love${NC} ${GREEN}Stack Overflow${NC}"
It works as expected if I source the file. However, running it as an executable results in the control codes being printed to the screen instead of the colors changing. I presume I need to send some flag to bash to enable the colors, but what?