-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-DuplicateThe issue is a duplicate.The issue is a duplicate.WG-Engine-Format
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
- Have Git for Windows installed
- Run Powershell 7.21 (either in ConHost or the new Terminal app, bug is reproducible in both)
- Create the following simple function:
function Test-Ansi {
$VerbosePreference = 'Continue'
Write-Verbose '------ Before ------'
& "$Env:ProgramFiles\Git\usr\bin\patch.exe" --help > $null
Write-Verbose '------ After ------'
}
- Observe properly formatted coloring for the line before
- Observe line after being uncolored and ANSI sequences instead printed verbatim
Additional Notes
This behaviour was only observed in PowerShell 7 - running the same function on PowerShell 5 yields the expected behaviour with no breaking changes to the ANSI output.
It also doesn't make a difference whether the redirection is done via | Out-Null or doing a $null assignment. Even just redirecting stderr via 2>$null triggers the issue. Not redirecting the command is the only way to have it run without breaking.
The issue also occurs independent of invocation, Invoke-Expression results in this bug as does using Start-Command.
Also running this slightly tweaked function:
function Test-Ansi-Async {
$VerbosePreference = 'Continue'
Write-Verbose '------ Before ------'
Start-Process -FilePath "C:\Program Files\Git\usr\bin\patch.exe" -RedirectStandardOutput NUL -ArgumentList '--help' -NoNewWindow
Write-Verbose '------ After ------'
}
will yield different bugs in ConHost or Windows Terminal:
- In ConHost browsing through command history will have corrupted output, with characters remaining on screen between history items
- In Windows Terminal the ANSI color codes of the next command will be corruped
(See screenshots for each case).
In both cases pressing "Enter" without any input restores proper output at the prompt.
Expected behavior
VERBOSE: ------ Before ------
VERBOSE: ------ After ------Actual behavior
VERBOSE: ------ Before ------
←[33;1mVERBOSE: ------ After ------←[0mError details
PS C:\Windows\System32› Get-Error
PS C:\Windows\System32›Environment data
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
Visual Corruption in ConHost
Broken ANSI Codes in Windows Terminal
Metadata
Metadata
Assignees
Labels
Needs-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.Resolution-DuplicateThe issue is a duplicate.The issue is a duplicate.WG-Engine-Format

