PowerShell / PowerShell/PowerShell

Write-Host redirection does not respect -NoNewLine parameter

Open
#25,436 1 comment 2 reactions 0 assignees View on GitHub

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
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.