Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect the NO_COLOR environment variable #73

Closed
suve opened this issue Sep 19, 2020 · 0 comments · Fixed by #74
Closed

Respect the NO_COLOR environment variable #73

suve opened this issue Sep 19, 2020 · 0 comments · Fixed by #74

Comments

@suve
Copy link
Owner

suve commented Sep 19, 2020

The NO_COLOR environment variable is an informal standard which states:

All command-line software which outputs text with ANSI color added should check for the presence of a NO_COLOR environment variable that, when present (regardless of its value), prevents the addition of ANSI color.

How it should work:

  1. If the --colour command-line option is explicitly specified, its value is used.
  2. If the --colour option is not specified (or specified as AUTO), then:
    a. Check if the NO_COLOR envvar is present. If it is, disable coloured output (NO).
    b. Check if stdout is attached to a terminal (isatty()). If it is, enable coloured output (YES).
    c. Otherwise, disable coloured output (NO).

The code, as it stands currently, performs steps 1, 2b and 2c, so this is a matter of adding the extra logic described in step 2a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant