Skip to content

Out-String cmdlet should support -NoNewline too #3684

@mklement0

Description

@mklement0

PSv5 brought the -NoNewline switch to the Set-Content (Add-Content) and Out-File cmdlets to allow direct concatenation of the input objects without newlines (strings among the input objects retain their embedded newlines however).

By default, these cmdlets blindly append an additional newline, whereas Out-String currently invariably does that, because it lacks -NoNewline.

For symmetry, Out-String should support -NoNewline too.

Current behavior

> (Out-String -InputObject 'a') -match '^a\r?\n$'
$True  # A trailing newline was added.

Desired behavior

> (Out-String -NoNewline -InputObject 'a') -match '^a$'
$True  # No trailing newline was added.

Environment data

PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestPotential candidate to participate in HacktoberfestIssue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions