config: respect NO_COLOR specification#778
Conversation
|
the test fails on windows for some weird reason |
|
Hi, Maybe I can query what platform Hadolint is running on and adjust the tests behavior accordingly? The case where the setting is applied because the environment variable is set to the empty string only needs to be tested on unixoids because on Windows that is "impossible ©️ ™️". |
|
@m-ildefons yeah, I think detecting the platform during the test and skipping that one on windows is best |
- Decide whether to print ANSI color codes or not based on the _presence_, not the value of the NO_COLOR environment variable The specification provided by https://no-color.org regarding the interpretation of the NO_COLOR environment variable specifically state that the value does not matter, only whether it is set or not should change program behavior. Therefore, Hadolint should respect that and ignore the value. There is a platform specific distinction in the test suite because on Windows it is expected that setting an environment variable to the empty string is equal to unsetting it, in contrast to POSIX platforms where an environment variable can be set to the empty string and still count as set. With $NO_COLOR it only matters if it is set, not what it is set to, the case on POSIX where it is set to the empty string should be respected.
84f4567 to
813a14b
Compare
|
great, thanks again! |
presence, not the value of the NO_COLOR environment variable
The specification provided by https://no-color.org regarding the
interpretation of the NO_COLOR environment variable specifically state
that the value does not matter, only whether it is set or not should
change program behavior.
Therefore, Hadolint should respect that and ignore the value.
How to verify it
Assuming no other settings are in place,
NO_COLOR= hadolint Dockerfileshould result in uncolored output just likeNO_COLOR=true hadolint DockerfileandNO_COLOR=n hadolint Dockerfile. Howeverunset NO_COLOR; hadolint Dockerfileshould give colored output.