Use bash builtin to check for tty.