simplify ecolor()

A linear branch is easier to read than multiple nested ifs.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
use for loop in color terminal detection

i is used as a generic loop counter.  This brings its initialization to
where the actual loop is and protects against the possibility of it
being set to an invalid value by another loop beforehand.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>