Use stdout instead of stdin for tty color checking
Closed this issue · 3 comments
Deleted user commented
Wouldn't it be better to check if stdout was a tty instead of using stdin when testing to see if output should be colorized?
grassator commented
I'm not on expert in C and terminal behaviour, so I just looked around for samples of code and all that I can find, points to tests for stdin
Deleted user commented
If you run the test executable with the output redirected to a file or piped to another process, then stdout will not be a tty, but stdin will be. Generally, this is when you do not want to see the escape codes.
For example, ls from coreutils uses stdout: https://github.com/coreutils/coreutils/blob/master/src/ls.c#L2027
grassator commented
@dales-at-avid Makes, sense, made the change