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

Consider supporting FORCE_COLOR environmental variable #71

Closed
matklad opened this issue Mar 2, 2023 · 4 comments
Closed

Consider supporting FORCE_COLOR environmental variable #71

matklad opened this issue Mar 2, 2023 · 4 comments

Comments

@matklad
Copy link

matklad commented Mar 2, 2023

This is more of a braindump rather than a well-considered feature request, as I am not an expert in the domain. The TL;DR is that there's FORCE_COLOR env variable, which is the opposite of NO_COLOR, and it might be nice to support it.

Background: I am writing a thing which spawns other processes (like cargo) via std::process::Command. The thing is definitely not a terminal emulator, so the subprocess stdout is normal pipe, rather than a TTY. My thing is also capable of parsing ANSI escapes, so it would very much like to receive colored output from subprocess. I wold love to have a general, cross-platform way to tell subprocesses "give me ANSI colors!" and I would love this not involving ioctl to the kernel (the way ttys work). The FORCE_COLOR feels like this solution.

However, there's a problem: unlike NO_COLOR, FORCE_COLOR isn't a "real standard". I think this is just a thing that node is doing. However, it seems like it at least becomes a de-facto standard. See, for example, the list of references in python/mypy#13806 (but, of course, node and python interpret this value differently: FORCE_COLOR=0 force-disables colors for node, and force-enables colors for Python).

@BurntSushi
Copy link
Owner

The problem is that there are multiple answers to this. For example, #41. And in practice, I'm not sure I really think the goal of "having one true way to force colors for applications" is probably just not going to happen unfortunately.

I resisted #41 because I don't really want to be in the business of just supporting a bunch of different random environment variables. I for example wonder whether it was right to add NO_COLOR support, but I'm not sure I want to expand on what I think might have been a mistake.

@matklad
Copy link
Author

matklad commented Mar 3, 2023

Yeah, it does seem that at this point this is just a "random environment variable". The momentum in the python ecosystem seems strong and recent though, so I wouldn't be surprised if this ends up a standard in the future, but it's wrong for termcolor to be a pioneer here. Probably best to close this issue (which is still valuable as a record of prior art!).

@matklad matklad closed this as completed Mar 3, 2023
@matklad
Copy link
Author

matklad commented Mar 3, 2023

For posterity, good recent summary of the state of things in this area: hashicorp/terraform#23708 (comment)

@BurntSushi
Copy link
Owner

The momentum in the python ecosystem seems strong and recent though, so I wouldn't be surprised if this ends up a standard in the future

Yeah... I would have said that about CLICOLOR too. Hell, there is even a Rust crate for it: https://github.com/mitsuhiko/clicolors-control

And the terraform folks hit the same issue I had when considering whether to add more environment variables: how do they interact with one another? Which one wins?

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

No branches or pull requests

2 participants