Open brlin-tw opened 2 weeks ago
Please provide more context on reproducing this because we already have a complex logic for determining if the output will be colored or not.
Take a look at should_do_markup method and put some breakpoints there to spot why is not behaving the way you expect. You might discover that it has good reasons to do it.
@ssbarnea
Please provide more context on reproducing this
The commands in the STEPS TO REPRODUCE section of the original report should be sufficient to reproduce the issue. I've updated the original report to be more specific.
Take a look at should_do_markup method and put some breakpoints there to spot why is not behaving the way you expect.
One problem I noticed is that the should_do_markup
method seems to be checking the standard output device to determine whether the output should be colorized, while most of Ansible-lint's output seems to be outputted to stderr
.
Also stream.isatty()
is only consulted as a final fallback, IMHO the reasoning behind doing so doesn't really make sense as:
- stdin.isatty() is the only one returning true, even on a real terminal
Shouldn't this be a bug in the implementation of stdin.isatty()
?
- stderr returning false if user user uses a error stream coloring solution
If the user has a specific use case that requires colorized output even when the output device isn't a terminal, they should specify --force-color
(or its equivalent) instead of relying on this fallback behavior.
Summary
Currently, Ansible-lint will output ASCII escape sequences that construct colorized output to the stderr even when it is not a terminal that can actually interpret them:
This causes unreadable output in applications that don't expect such output such as Git Cola:
Please only output colorized messages when:
--force-color
command option or theFORCE_COLOR
environment variable.Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
Run the following commands in a text terminal on a Unix-like operating system:
Desired Behavior
ASCII escape sequences do not appear in the output, as in:
Actual Behavior
ASCII escape sequences do appear in the output.