Title: The -NoNewLine switch parameter of Out-File and Out-String should not strip embedded newlines from formatter-generated output · Issue #5107 · PowerShell/PowerShell · GitHub
Open Graph Title: The -NoNewLine switch parameter of Out-File and Out-String should not strip embedded newlines from formatter-generated output · Issue #5107 · PowerShell/PowerShell
X Title: The -NoNewLine switch parameter of Out-File and Out-String should not strip embedded newlines from formatter-generated output · Issue #5107 · PowerShell/PowerShell
Description: Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets not to place a newline after each (output representation of) the input object - in other words: the input objects' (representations) are directly ...
Open Graph Description: Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets not to place a newline after each (output representation of) the input object - in other words: the input ...
X Description: Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets not to place a newline after each (output representation of) the input object - in other words: the input ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/5107
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The -NoNewLine switch parameter of Out-File and Out-String should not strip embedded newlines from formatter-generated output ","articleBody":"\u003csup>Follow-up to #3684.\u003c/sup>\r\n\r\nWith _multiple_ input objects, the `-NoNewline` switch causes said cmdlets not to place a newline after each (output representation of) the input object - in other words: the input objects' (representations) are _directly concatenated_.\r\n\r\nWhile the usefulness of this behavior is debatable, it should work consistently with respect to how newlines _embedded_ in input object representations are handled.\r\n\r\nCurrently, \r\n\r\n* formatter-generated output representations have their embedded newlines _stripped_\r\n\r\n* `.ToString()` generated output representations have their embedded newlines _preserved.\r\n\r\nIt is the latter behavior that should be consistently applied.\r\n\r\n\r\nSteps to reproduce:\r\n------------------\r\n\r\n```powershell\r\n([pscustomobject] @{ one = 1 }), \"two`nthree\" | Out-File -NoNewline t.txt; Get-Content -raw t.txt\r\n```\r\nNote how the first input object uses the PS formatting system, whereas the second one doesn't.\r\n\r\nActual behavior:\r\n-----------------\r\n\r\n```powershell\r\none--- 1two\r\nthree # no trailing newline\r\n```\r\nNote how the internal newlines were stripped from the default output formatting for `@{ one = 1 }`, which is:\r\n\r\n```\r\n\r\none\r\n---\r\n 1\r\n\r\n```\r\n\r\nExpected behavior:\r\n-----------------\r\n\r\n```powershell\r\n\r\none\r\n---\r\n 1two\r\nthree # no trailing newline\r\n```\r\n\r\nYou could argue that `-NoNewline` with formatter-generated output doesn't make much sense with _multiple_ input objects, and the mixing with `.ToString()` formatted objects produces strange effects, but stripping all embedded newlines makes even less sense.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-beta.8\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-10-13T13:14:58Z","url":"https://github.com/PowerShell/PowerShell/issues/5107"}
| 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:714d8460-5b11-21d6-855c-6da9ca63bd0c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F64:3A715F:ACFC07:F7B2F3:6AFDA442 |
| html-safe-nonce | 6c78d4f3994e4d44cec02b4748b86cf0ca90fc246cfea4d445d8f970e3322808 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjY0OjNBNzE1RjpBQ0ZDMDc6RjdCMkYzOjZBRkRBNDQyIiwidmlzaXRvcl9pZCI6IjEzMTI2NDY3NjU5OTk5MjQyOTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2abaf84b0e5ba5dafa468cee6159c2021b65823b50d28084d3a783a474c03350 |
| hovercard-subject-tag | issue:265285067 |
| 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/5107/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e51aa3aa8c7894784b1973f57b0a74c8ee617555ac907839c6672715b075e920/PowerShell/PowerShell/issues/5107 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e51aa3aa8c7894784b1973f57b0a74c8ee617555ac907839c6672715b075e920/PowerShell/PowerShell/issues/5107 |
| og:image:alt | Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets not to place a newline after each (output representation of) the input object - in other words: the input ... |
| 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 | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| 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 | 0ddf53eb35c87f1f8df13dbf75c3bdadbfc6e969 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width