Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unpredictable ordering of native command output when merging the error stream into the success output stream #5424

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Steps to reproduce

bash -c 'echo a; echo b >&2; echo c' 2>&1

On Windows, use cmd /c 'echo a & echo b >&2 & echo c' 2>&1.
Additionally, in Windows PowerShell, append | % tostring.

Note that it is the addition of 2>&1 that triggers the problem.

Expected behavior

a
b
c

That is, the output lines should be printed in the order written, across streams.

Actual behavior

Intermittently, the output order is unexpected in that the stderr output line is printed out of order; e.g.:

a
c
b

or

b
a
c

If you have trouble seeing the symptom, try something like the following

Unix:

while ($true) { if (($a = bash -c 'echo a; echo b >&2; echo c' 2>&1)[1] -notmatch 'b') { $a; break} }

Windows:

while ($true) { if (($a = cmd /c 'echo a & echo b >&2 & echo c' 2>&1 | % tostring)[1] -notmatch 'b') { $a; break}  }

Environment data

PowerShell Core v6.0.0-beta.9 on macOS 10.13
PowerShell Core v6.0.0-beta.9 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0-beta.9 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.674 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.