Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
regression with tty detection #1459
Comments
|
I cannot reproduce, what is your terminal emulator, shell, etc. no-color.org is flawed in that |
|
I can't reproduce in zsh either |
|
The terminal is irrelevant (same with iTerm or native Terminal) but the shell type and configuration is relevant: it will reproduce with zsh only if you add the mentioned script for colorizing the stderr console. That snippet is a subset of https://github.com/cehoffman/dotfiles/blob/master/zsh/config#L171-L193 which I adopted long time ago. If the A simple test of ``pre-commit 1>/dev/null` demonstrates that default stream is stdout, so we cannot really blame stderr stream for breaking stdout output. In fact there is an even easier way to reproduce wrong assumption:
Once you redirect stderr to a file, it looses the tty properly, which is fine. Still, what is not fine is that the app stops producing ANSI only stdout. |
|
well we can't pick stdout because it breaks windows, stderr works fine without your configuration so I'd say that's a your-configuration problem |
|
I (effectively) beg to differ as this can easily happen with redirection anywhere. At the same time I do understand that you do no want to break the Windows hack too, so I will try to investigate the subject more in order too see how others sorted the issue. |
|
could maybe use one on one and one on the other? |
|
I've created an issue on git-for-windows: git-for-windows/git#2914 |



A recent regression was introduced via #1382 which broke detection on various conditions.
For example, on my MacOS host, only
stdoutandstdinreport True onisatty()whilestderrreports False, even if in reality there is no problem with sending ANSI to stderr.Probably we should rely solely on
stdoutfor the test or to assure that we respect it for each tty.This issue is not happening with lots of people because only few of them use a method to colorize stderr, which apparently is what has a side-effect of marking it as a non tty.
Example of zsh snippet from
~/.zshrcthat does this:Once this runs you no longer gave a tty-enabled stderr.
Vast majority of CLI tools I know are using
sys.stdout.isatty(), the only other exception I know ismypy. https://bixense.com/clicolors/ seems to support that approach too.Regarding the never-ending struggle to control ANSI on/off behavior where each tool invented its own implementation and variables to configure behavior, it seems that someone realized that maybe is time to do something about it https://no-color.org/ :)