Setting the TERM environment variable to 'dumb' doesn't prevent use of VT (ANSI) escape sequences by the formatting system · Issue #16059 · PowerShell/PowerShell · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Setting the TERM environment variable to 'dumb' doesn't prevent use of VT (ANSI) escape sequences by the formatting system #16059
While setting the TERM environment variable to 'dumb' does make $host.UI.SupportsVirtualTerminal report $false, the output-formatting system still uses VT (ANSI) escape sequences and produces colored output.
Note: Unlike setting TERM to xtermm / xterm-mono, dumb does not cause $PSStyle.OutputRendering to reflect PlainText (arguably, if PowerShell knows that the terminal doesn't support VT (ANSI) escape sequences, it shouldn't use them, irrespective of the value of $PSStyle.OutputRendering).
# On Unix
sh -c 'TERM=dumb pwsh -c ''Get-Item /'''
Expected behavior
The output shouldn't be colored.
Actual behavior
The output is colored.
Note: On Windows, the equivalent $env:TERM='dumb'; pwsh -nop -c 'Get-Item /' command doesn't render the colors, but outputs the escape sequences as-is, with the ESC char. represented as ←
Activity
rkeithhill commentedon Oct 28, 2021
I think this is fixed in rc.1. Also note, that I invoke
pwsh-previewhere instead ofpwshwhich on my ubuntu is 7.0.0.I see this code was added a few months ago:
PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHostUserInterface.cs
Lines 69 to 80 in ffd06eb
iSazonov commentedon Oct 28, 2021
It was fixed in Preview.5 as experimental feature.