Do not print escape-sequences in files
flimberger opened this issue · comments
Colours are nice, but the escape sequences used to produce them in the terminal are problematic when the output is redirected into a file. The usual approach is to check whether the output is a terminal with isatty(3)
and to suppress coloured output if it is not.
The downside is that this is that piping through less(1)
will not work anymore with colours.
The downside is that this is that piping through less(1) will not work anymore with colours.
Yes, but this is expected behavior. E.g the command
ls -l
has color in my terminal, but
ls -l | less
does not.
I have thought about it, and I consider putting binary data into a file a bug. A fix is underway.