You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
$ ansible-lint /dev/null 2>out
$ xxd out | head --lines=1
00000000: 0a1b 5b33 326d 5061 7373 6564 1b5b 306d ..[32mPassed.[0m
This causes unreadable output in applications that don't expect such output such as Git Cola:
Please only output colorized messages when:
The output device is a terminal device.
The user explicitly overrides the behavior via the --force-color command option or the FORCE_COLOR environment variable.
Issue Type
Bug Report
OS / ENVIRONMENT
ansible-lint 24.9.2 using ansible-core:2.17.4 ansible-compat:24.9.1 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
ansible installation method: pip(via pipx)
ansible-lint installation method: pip(via pipx)
STEPS TO REPRODUCE
Run the following commands in a text terminal on a Unix-like operating system:
ansible-lint /dev/null 2>outxxd out | head --lines=1
Desired Behavior
ASCII escape sequences do not appear in the output, as in:
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.
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.
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
ansible-lint 24.9.2 using ansible-core:2.17.4 ansible-compat:24.9.1 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
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.
The text was updated successfully, but these errors were encountered: