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

Piping Text to Select-String Shows ANSI Escape Sequences Instead of Color #9404

Closed
chrisbehanna opened this issue Mar 7, 2021 · 4 comments
Closed
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@chrisbehanna
Copy link

Environment

Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd] Windows 10 Enterprise 10.0.19042.0
Windows Terminal version (if applicable): 1.6.10571.0

Any other software? PowerShell Core 7.1.2

Steps to reproduce

git ls-remote | Select-String git_gc

Expected behavior

A listing of the matching remote branches, with the string "git_gc" highlighted in color

Actual behavior

ff0f34e411366ca6a25b7e94ff2df0a1827e3bc8 refs/heads/build/←[7mgit_gc←[0m

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 7, 2021
@DHowett
Copy link
Member

DHowett commented Mar 7, 2021

This is because git is disabling ANSI coloring shortly after it launches, even when it is redirected. This is a long-standing Cygwin/msys2 bug.

@DHowett DHowett closed this as completed Mar 7, 2021
@chrisbehanna
Copy link
Author

This is because git is disabling ANSI coloring shortly after it launches, even when it is redirected. This is a long-standing Cygwin/msys2 bug.

Then how does git log --graph --color --decorate apply color?

@DHowett
Copy link
Member

DHowett commented Mar 24, 2021

So truthfully, it's a little more nuanced than that. There's a more detailed write-up here: #4921 (comment)

There's some combination of process entry/exit and mode transition that results in VT being disabled when it should be enabled when git or a subprocess exits after control has returned to something that required VT to be on. In the git log case, nobody appears to be exiting and reconfiguring the console.

@chrisbehanna
Copy link
Author

Thanks for the additional detail. For now, I'll just use Select-String -NoEmphasis when running git ls-remote to look for particular branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
Development

No branches or pull requests

2 participants