Title: Add a -NoLastNewline switch parameter to Write-Host, Set-Content, Add-Content, Out-File, Out-String · Issue #5108 · PowerShell/PowerShell · GitHub
Open Graph Title: Add a -NoLastNewline switch parameter to Write-Host, Set-Content, Add-Content, Out-File, Out-String · Issue #5108 · PowerShell/PowerShell
X Title: Add a -NoLastNewline switch parameter to Write-Host, Set-Content, Add-Content, Out-File, Out-String · Issue #5108 · PowerShell/PowerShell
Description: Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets to not only omit a trailing (last) newline, but also not to place newlines between the (output representations of) the input objects on output. Ho...
Open Graph Description: Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets to not only omit a trailing (last) newline, but also not to place newlines between the (output representat...
X Description: Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets to not only omit a trailing (last) newline, but also not to place newlines between the (output representat...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/5108
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add a -NoLastNewline switch parameter to Write-Host, Set-Content, Add-Content, Out-File, Out-String","articleBody":"\u003csup>Follow-up to #3684.\u003c/sup>\r\n\r\nWith _multiple_ input objects, the `-NoNewline` switch causes said cmdlets to not only omit a _trailing_ (last) newline, but also not to place newlines _between_ the (output representations of) the input objects on output.\r\n\r\nHowever, perhaps more typically, you want to only suppress a _trailing_ newline, so it would be handy to have a `-NoLastNewline` parameter (mutually exclusive with `-NoNewLine`) that does just that.\r\n\r\nIf #3855 gets implemented, an alias `-NoLastDelimiter` could be defined, which would effectively turn the application of the delimiter from _terminator_ logic (place delimiter after _every_ item, including the last) into _separator_ logic (place delimiter only _between_ items).\r\n\r\nDesired behavior\r\n------------------\r\n\r\n* `Out-String` example:\r\n\r\n```powershell\r\nPS> 'a', 'b' | Out-String -NoLastNewline\r\na\r\nb\r\n```\r\n\r\nNote that without `-NoLastNewLine` you'd get a blank line at the end, due to an extraneous newline getting appended, as discussed in #14444 (which asked for `-NoLastNewLine` to become the _default_ behavior, but that was [declined due to backward-compatibility concerns](https://github.com/PowerShell/PowerShell/issues/14444#issuecomment-1473683009)).\r\n\r\n* `Write-Host` example:\r\n\r\n```powershell\r\nPS> 'a', 'b' | Write-Host -NoLastNewline; Write-Host 'c'\r\na\r\nbc\r\n```\r\n\r\nNote that with `-NoNewline` you'd get `abc`.\r\n\r\nInput object-_internal_ (embedded) newlines should be left untouched by both `-NoLastNewline` and\r\n`-NoNewline` (though the latter doesn't do so consistently at present - see #5107).\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\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:15:11Z","url":"https://github.com/PowerShell/PowerShell/issues/5108"}
| 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:af30c76b-285a-53fc-88c5-ce65970459ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A0C:292B7E:2B8F7E:3C0DA8:6AFDA393 |
| html-safe-nonce | 62f89cced1fe17f43e9a3f3ca4afdc3758ea2239e8e9046513624a411bea1509 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTBDOjI5MkI3RToyQjhGN0U6M0MwREE4OjZBRkRBMzkzIiwidmlzaXRvcl9pZCI6IjY5NDI5MDg2NTY5MDgwODQxMTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c31da7684b33315832762492646743f3fa573863111ea2eac4235db29063d107 |
| hovercard-subject-tag | issue:265285141 |
| 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/5108/issue_layout |
| twitter:image | https://opengraph.githubassets.com/95eb89607fdadfb923f03473d0a3adce1d232e8f6173af086db43ee093bb3ff0/PowerShell/PowerShell/issues/5108 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/95eb89607fdadfb923f03473d0a3adce1d232e8f6173af086db43ee093bb3ff0/PowerShell/PowerShell/issues/5108 |
| og:image:alt | Follow-up to #3684. With multiple input objects, the -NoNewline switch causes said cmdlets to not only omit a trailing (last) newline, but also not to place newlines between the (output representat... |
| 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