PowerShell / PowerShell/PowerShell
Write-Host redirection does not respect -NoNewLine parameter
Open
Nobody has claimed this yet.
Needs-Triage
WG-Interactive-Console
WG-NeedsReview
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
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
The -NoNewLine parameter on Write-Host is not being respected when the Information stream is redirected.
Possibly related to the lack of -NoNewLine on Write-Information and friends #17618, #5579
Expected behavior
In file test.ps1:
Write-Host -NoNewLine "Hello"
Write-Host "World"
PS C:\Users> .\test.ps1
HelloWorld
PS C:\Users> .\test.ps1 6>&1
HelloWorld
Actual behavior
In file test.ps1:
Write-Host -NoNewLine "Hello"
Write-Host "World"
PS C:\Users> .\test.ps1
HelloWorld
PS C:\Users> .\test.ps1 6>&1
Hello
World
Error details
Environment data
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided test.ps1 commands in PowerShell 7.5.0, including the Information-stream redirection, and compare the two outputs. No implementation file or test is named in the issue; done means that Write-Host -NoNewLine produces HelloWorld both normally and when stream 6 is redirected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100