Title: 7.4.0 File redirection with native executable no longer appends new line · Issue #20811 · PowerShell/PowerShell · GitHub
Open Graph Title: 7.4.0 File redirection with native executable no longer appends new line · Issue #20811 · PowerShell/PowerShell
X Title: 7.4.0 File redirection with native executable no longer appends new line · Issue #20811 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/20811
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"7.4.0 File redirection with native executable no longer appends new line","articleBody":"### Prerequisites\n\n- [X] Write a descriptive title.\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\n- [X] Search the existing issues.\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\n\n### Steps to reproduce\n\nAccording to [about_Redirection](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_redirection?view=powershell-7.4):\r\n\u003e Using the redirection operator with a file target is functionally equivalent to piping to Out-File with no extra parameters.\r\n\r\nThe documentation for [Out-File](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-file?view=powershell-7.4) `-NoNewLine` says:\r\n\u003e No newline is added after the last output string.\r\n\r\nWhich means `Out-File` does normally add a newline. And this is what you see in PowerShell 7.3.10. If the output does not end in a newline, `Out-File` and file redirection add a newline. **But in PowerShell 7.4.0, with file redirection that newline is no longer added.** \r\n\r\nTo make this easy to repro you'll want a native executable that outputs character data but no newline (LF or CR/LF) _at the end_. Here's a C# program that does that. You *don't have to* use this program to repro the problem. It just helps.\r\n```\r\nnamespace Example;\r\n\r\ninternal class Program\r\n{\r\n static void Main()\r\n {\r\n Console.Write(\"Hello\"); // Note that it's not WriteLine()\r\n }\r\n}\r\n```\r\n\r\nThis appears to be related to the PR: https://github.com/PowerShell/PowerShell/pull/17857 by @SeeminglyScience that was added in preview 4\r\n\r\nAppears to be related to #20747 and #20808.\n\n### Expected behavior\n\n```console\n# See \"Steps to reproduce\" for source code for Hello.exe\r\n\r\nPS\u003e .\\Hello.exe \u003ex.txt\r\n\r\nPS\u003e (Get-Content x.txt -Raw).EndsWith([System.Environment]::NewLine)\r\nTrue\n```\n\n\n### Actual behavior\n\n```console\n# See \"Steps to reproduce\" for source code for Hello.exe\r\n\r\nPS\u003e .\\Hello.exe \u003ex.txt\r\n\r\nPS\u003e (Get-Content x.txt -Raw).EndsWith([System.Environment]::NewLine)\r\nFalse\n```\n\n\n### Error details\n\n```console\nN/A\n```\n\n\n### Environment data\n\n```powershell\nName Value\r\n---- -----\r\nPSVersion 7.4.0\r\nPSEdition Core\r\nGitCommitId 7.4.0\r\nOS Microsoft Windows 10.0.19044\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\n```\n\n\n### Visuals\n\n### 7.3.10\r\n\r\n\r\n### 7.4.0\r\n\r\n","author":{"url":"https://github.com/twinter-amosfivesix","@type":"Person","name":"twinter-amosfivesix"},"datePublished":"2023-11-29T17:55:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/20811/PowerShell/issues/20811"}
| 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:f7b3b13f-8ba7-bd06-8ae9-1adbe4a01c49 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9CD6:F01E1:3841236:4D91823:6A54B386 |
| html-safe-nonce | d7c878814a4925dc03c3b705553d304ec792adac444addcd7e5550de27bdaeb9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0Q2OkYwMUUxOjM4NDEyMzY6NEQ5MTgyMzo2QTU0QjM4NiIsInZpc2l0b3JfaWQiOiI1ODM5MjAxNTI0Njc3NjUzMzgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 78bcb85c960f6643ccdf4c3ea2858bd21455b78c98adf4946ed397d9f3dc4b05 |
| hovercard-subject-tag | issue:2017130371 |
| 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/20811/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1b48d21b71f4802599b365e8e96c3ab65433d807f96dcabd49c0ae0d78d2827a/PowerShell/PowerShell/issues/20811 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1b48d21b71f4802599b365e8e96c3ab65433d807f96dcabd49c0ae0d78d2827a/PowerShell/PowerShell/issues/20811 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | twinter-amosfivesix |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 5d343e1152573ef294b28f54e4a14fb5fdb3a5a1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width