Skip to content

Add a parameter to Out-File and Out-String to bring back the previous behavior that got changed by #17455 #17509

@daxian-dbw

Description

@daxian-dbw

For reference:

Context summary

The previous behavior in 7.2.x is: Out-File and Out-String remove escape sequences from the passed-in strings when $PSStyle.OutputRendering is Host or PlainText.

There are some problems with this behavior, especially when having Host to be the default value for $PSStyle.OutputRendering. See #17455 (comment) for the details of those problems.

Therefore, that behavior was changed by #17455 to be:

  • when the input object is pure string, these 2 cmdlets keep the string input unchanged regardless of the RenderingOutput setting
  • 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 RenderingOutput setting, which is the same as the existing behavior.

Recommendation from PowerShell Committee

The committee reviewed #17455 and recommended to add a new parameter to Out-String and Out-File to keep the previous behavior. Quote the comments #17455 (review) and #17455 (comment) below:

I think we should seriously consider adding a parameter to out-string and out-file which retains our current behavior. Perhaps a parameter -AsPlainText or some such will allow users to have the older behavior while we provide a safer default behavior.

powershell-committee reviewed this, we would recommend adding a parameter to enable users to get back the previous behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions