-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Get-Content -Delimiter unexpectedly keeps the delimiter in the lines returned #3706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@MaximoTrinidad: The other issue is somewhat related, though in the case of |
Thanks @mklement0! |
I agree that both should work uniformly And it is an other issue - /cc @jeffbi |
Historically, there's been a lot of confusion around the terms separator, delimiter, and terminator. I agree that Therefore, bypassing the secondary issue of line vs. record, perhaps defining |
@mklement0 We could rely on the W3C standard - Model for Tabular Data and Metadata on the Web |
In the context of CSV files, specifically, which are line-oriented, line terminator is the right term. By contrast, by allowing arbitrary terminator strings with In other words: the units of data may themselves be multi-line, so calling such a unit a line is inappropriate. That's why On a meta note: even though the label of your link suggests that it is to a specific comment on the issue page, the link is just to the issue page itself. |
@mklement0 You can copy such links from post header datetime string "mklement0 commented 9 minutes ago". |
…lements returned (PowerShell#3706) - functional changes
…lements returned (PowerShell#3706) - formatting changes
…lements returned (#3706) - functional changes
…lements returned (#3706) - formatting changes
The issue is still not resolved. Why has it been marked "Resolution Fixed"? @mklement0 @iSazonov |
@shreyjain362, it has been fixed in PowerShell 7 (which this repo is solely devoted to) - at least judging by running the original reproduction steps. Note that Windows PowerShell won't receive this fix, because it is no longer actively developed and only receives security-critical fixes. |
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 the lines it returns.The generalization of this concept is to use the
-Delimiter
parameter, which allows specifying a custom line (record) delimiter (terminator / separator).However, unlike with the default delimiter - a newline - whatever
-Delimiter
argument you specify is kept in the lines returned, which is:an inconsistency
an inconvenience, because the delimiter - which by its nature is not part of the data itself - must be stripped explicitly before further processing.
Steps to reproduce
I'd expect the following 2 commands to be equivalent:
Expected behavior
Actual behavior
Note how the trailing newlines were retained in the output from the 2nd command.
Environment data
The text was updated successfully, but these errors were encountered: