Title: Get-Content -Delimiter unexpectedly keeps the delimiter in the lines returned · Issue #3706 · PowerShell/PowerShell · GitHub
Open Graph Title: Get-Content -Delimiter unexpectedly keeps the delimiter in the lines returned · Issue #3706 · PowerShell/PowerShell
X Title: Get-Content -Delimiter unexpectedly keeps the delimiter in the lines returned · Issue #3706 · PowerShell/PowerShell
Description: Note: It may be too late to change this behavior, or perhaps it falls into Bucket 3: Unlikely Grey Area. If the former, perhaps a -TrimDelimiter option could be added. By default, Get-Content strips the newline character [sequence] from ...
Open Graph Description: Note: It may be too late to change this behavior, or perhaps it falls into Bucket 3: Unlikely Grey Area. If the former, perhaps a -TrimDelimiter option could be added. By default, Get-Content strip...
X Description: Note: It may be too late to change this behavior, or perhaps it falls into Bucket 3: Unlikely Grey Area. If the former, perhaps a -TrimDelimiter option could be added. By default, Get-Content strip...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3706
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Get-Content -Delimiter unexpectedly keeps the delimiter in the lines returned","articleBody":"Note: It may be too late to change this behavior, or perhaps it falls into [Bucket 3: Unlikely Grey Area](https://github.com/PowerShell/PowerShell/blob/master/docs/dev-process/breaking-change-contract.md#bucket-3-unlikely-grey-area).\r\nIf the former, perhaps a `-TrimDelimiter` option could be added.\r\n\r\nBy default, `Get-Content` strips the newline character [sequence] from the lines it returns.\r\n\r\nThe generalization of this concept is to use the `-Delimiter` parameter, which allows specifying a custom line (record) delimiter (terminator / separator).\r\n\r\nHowever, unlike with the default delimiter - a newline - whatever `-Delimiter` argument you specify is _kept_ in the lines returned, which is:\r\n\r\n* an inconsistency\r\n\r\n* an inconvenience, because the delimiter - which by its nature is not part of the data itself - must be stripped explicitly before further processing.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\nI'd expect the following 2 commands to be equivalent:\r\n\r\n```powershell\r\n1,2 \u003e t.txt; get-content t.txt | % { \"[$_]\" }\r\n1,2 \u003e t.txt; get-content -delimiter ([environment]::newline) t.txt | % { \"[$_]\" }\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n```PowerShell\r\n[1]\r\n[2]\r\n[1]\r\n[2]\r\n```\r\n\r\nActual behavior\r\n---------------\r\n\r\n```PowerShell\r\n[1]\r\n[2]\r\n[1\r\n]\r\n[2\r\n]\r\n```\r\n\r\nNote how the trailing newlines were retained in the output from the 2nd command.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on macOS 10.12.4\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-05-05T15:13:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/3706/PowerShell/issues/3706"}
| 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:0f482f4e-62f6-aa7b-c7f0-58304823fcc8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D10E:37F578:334FC5F:4998170:6A56869B |
| html-safe-nonce | c8ba9acec034cd60865abdcb1dcc7963b32a41164a9e8eabf7c9b207ed854f29 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTBFOjM3RjU3ODozMzRGQzVGOjQ5OTgxNzA6NkE1Njg2OUIiLCJ2aXNpdG9yX2lkIjoiMjY0NDA4MjUzMDM1MDE3MTgwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 6ff0cf942c6b523a2916fb0a70d79406f02dfa3fd7ad91516bfb85d59eb24338 |
| hovercard-subject-tag | issue:226604385 |
| 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/3706/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aa15e5fe6fa486539c63934034eceed1ae588eb70e948a40e43e2533b6344992/PowerShell/PowerShell/issues/3706 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aa15e5fe6fa486539c63934034eceed1ae588eb70e948a40e43e2533b6344992/PowerShell/PowerShell/issues/3706 |
| og:image:alt | Note: It may be too late to change this behavior, or perhaps it falls into Bucket 3: Unlikely Grey Area. If the former, perhaps a -TrimDelimiter option could be added. By default, Get-Content strip... |
| 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 | 19b5ee9431dcfce15ab4b001d626e4e3a6ba1acb7be814813a52bbebd9a86ef5 |
| 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 | fc131753d059926755b1ab26f13a2c96a692f5d7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width