Now I use test to verify whether stdout is attached to tty or not