Skip to content

7.4.0 Redirecting stdout and stderr to Two Separate Files Leaves Empty Files #20747

@twinter-amosfivesix

Description

@twinter-amosfivesix

Prerequisites

Steps to reproduce

When I redirect the output and error streams of a native command to two separate files (when I know the command writes to the error stream), both files are created but they are both empty. The error file should contain content. If I redirect only the error stream, the file will contain the correct content.

Here I'm using dotnet as an example but the same thing happens with other commands. If you run dotnet garbage it will write to the error stream.

dotnet >x.txt 2>y.txt garbage

Expected behavior

PS> dotnet >x.txt 2>y.txt garbage
                                                                                                              PS> Get-Content y.txt
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application 'garbage' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.

Download a .NET SDK:
https://aka.ms/dotnet-download

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

Actual behavior

PS> dotnet >x.txt 2>y.txt garbage
                                                                                                                                                                                 PS> Get-Content y.txt
                                                                                                                                                                                 PS> dotnet 2>y.txt garbage
                                                                                                                                                                                 PS> Get-Content y.txt
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-garbage does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

Error details

N/A

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

image

image

Metadata

Metadata

Labels

In-PRIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the product

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions