Skip to content

Error stream and ErrorRecords #1465

Closed
Closed

Description

@vors

Context

On Linux, it's common to use error stream (2) as an information stream.
There is no errors in this case, it's just a way to report info.
When PowerShell redirects error stream, it wraps all output from stream 2 in NativeCommandError ErrorRecord.

That doesn't happen for interactive experience (when there is no redirection), but it shows up in logs, scripting and non-console powershell hosts (i.e. PowerShell ISE).

Steps to reproduce

grep 2>txt
cat txt

On windows, you can use grep that comes with git to do the same.

Expected behavior

Usage: /usr/bin/grep [OPTION]... PATTERN [FILE]...
Try '/usr/bin/grep --help' for more information.

Actual behavior

grep : Usage: /usr/bin/grep [OPTION]... PATTERN [FILE]...
At line:1 char:1
+ grep 2>txt
+ ~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Usage: /usr/bin...TTERN [FILE]...:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Try '/usr/bin/grep --help' for more information.

Environment data

Any version of powershell

Activity

  1. added
    Usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability
    on Jul 21, 2016
  2. added this to the milestone on Jul 26, 2016
  3. vors commented on Jul 26, 2016

    @vors
    CollaboratorAuthor

    Per discussion with Jason Shirk (@lzybkr) , we will do this change for public release

  4. added a commit that references this issue on Aug 6, 2026
    c50086c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Usability(LEGACY) Helps filter issues that might be higher priority because they directly affect usability

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions