-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Prerequisites
- Write a descriptive title.
- Search the existing issues.
Summary of the new feature or changed behavior
The issue: PowerShell/PowerShell#17452
The PR: PowerShell/PowerShell#17455
The changes in this PR update the behavior of Out-File and Out-String regarding the RenderingOutput setting to be the following:
- when the input object is pure string, these 2 cmdlets keep the string input unchanged regardless of the
RenderingOutputsetting - when the input object needs to have formatting views applied to it, these 2 cmdlets remove escape sequences from the formatting output strings based on the
RenderingOutputsetting.
List of articles that need to be updated
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_ansi_terminals?view=powershell-7.2, more specifically, the section about OutputRendering enum.
We should call out that $PSStyle.OutputRendering affect formatting and text rendering on console screen, but it doesn't affect other scenarios. Example, $PSStyle.Foreground.Red + "abc" + $PSStyle.Reset | % { $_.Length } returns 12 regardless of $PSStyle.OutputRendering.
Out-File and Out-String respect $PSStyle.OutputRendering when the piped-in object needs to be applied with formatting views. Otherwise, it keeps the escape sequences regardless of $PSStyle.OutputRendering, such as when the piped-in object are pure strings.