Title: Unpredictable ordering of native command output when merging the error stream into the success output stream · Issue #5424 · PowerShell/PowerShell · GitHub
Open Graph Title: Unpredictable ordering of native command output when merging the error stream into the success output stream · Issue #5424 · PowerShell/PowerShell
X Title: Unpredictable ordering of native command output when merging the error stream into the success output stream · Issue #5424 · PowerShell/PowerShell
Description: 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 pro...
Open Graph Description: 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 th...
X Description: 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...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/5424
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unpredictable ordering of native command output when merging the error stream into the success output stream","articleBody":"Steps to reproduce\r\n------------------\r\n\r\n```powershell\r\nbash -c 'echo a; echo b >&2; echo c' 2>&1\r\n```\r\n\r\nOn Windows, use `cmd /c 'echo a & echo b >&2 & echo c' 2>&1`.\r\nAdditionally, in _Windows PowerShell_, append `| % tostring`.\r\n\r\nNote that it is the addition of `2>&1` that triggers the problem.\r\n\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```none\r\na\r\nb\r\nc\r\n```\r\nThat is, the output lines should be printed in the order written, across streams.\r\n\r\nActual behavior\r\n---------------\r\n\r\n_Intermittently_, the output order is unexpected in that the stderr output line is printed out of order; e.g.:\r\n\r\n```none\r\na\r\nc\r\nb\r\n```\r\n\r\nor \r\n\r\n```none\r\nb\r\na\r\nc\r\n```\r\n\r\nIf you have trouble seeing the symptom, try something like the following\r\n\r\nUnix:\r\n\r\n```powershell\r\nwhile ($true) { if (($a = bash -c 'echo a; echo b >&2; echo c' 2>&1)[1] -notmatch 'b') { $a; break} }\r\n```\r\n\r\nWindows:\r\n\r\n```powershell\r\nwhile ($true) { if (($a = cmd /c 'echo a & echo b >&2 & echo c' 2>&1 | % tostring)[1] -notmatch 'b') { $a; break} }\r\n```\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-beta.9 on macOS 10.13\r\nPowerShell Core v6.0.0-beta.9 on Ubuntu 16.04.3 LTS\r\nPowerShell Core v6.0.0-beta.9 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\r\nWindows PowerShell v5.1.15063.674 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-11-12T03:11:47Z","url":"https://github.com/PowerShell/PowerShell/issues/5424"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8b4f1607-34c3-eb42-59ee-f1b54d0bddb3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E93E:31E3B3:15B51F:1D7D98:6AFD4D75 |
| html-safe-nonce | e8950cf5de7479d0118b0f0bc90c67b75dff6a1f9fa9af1f488dc1aa8d5ac7c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTNFOjMxRTNCMzoxNUI1MUY6MUQ3RDk4OjZBRkQ0RDc1IiwidmlzaXRvcl9pZCI6IjczODQyMjI2MTk2NTU4MTg2MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | be8d180bd70aa9d753143279ce15dcb3239041db3739666e95e48e31e378f7f6 |
| hovercard-subject-tag | issue:273195201 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/5424/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5d54e5535a1cc22ab0cf7fce1b1a5c5beb2f0b9138929df75814271765e367c8/PowerShell/PowerShell/issues/5424 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5d54e5535a1cc22ab0cf7fce1b1a5c5beb2f0b9138929df75814271765e367c8/PowerShell/PowerShell/issues/5424 |
| og:image:alt | 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 th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width