Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ private bool ReadDelimited(bool waitChanges, ArrayList blocks, bool readBackward
// (Trimming it during backward reading would not only be unnecessary, but could interfere with determining the correct start position.)
string contentString = content.ToString();
blocks.Add(
!readBackward && contentString.EndsWith(actualDelimiter, StringComparison.Ordinal)
!readBackward && contentString.EndsWith(actualDelimiter, StringComparison.Ordinal) && !_isRawStream

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good;
but original issue says that "Note that Windows Powershell is not affected".
Any ideas why this does not repro in Windows PS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the code is introduced by core ps code change.

? contentString.Substring(0, content.Length - actualDelimiter.Length)
: contentString
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,17 @@ baz
}
}
}

Describe "Get-Content -Raw test" -Tags "CI" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test code is a good candidate to be rewritten using -testcases construct, as per testing guidelines.


It "Reads - <testname> in full" -TestCases @(
@{character = "a`nb`n"; testname = "LF-terminated files"; filename = "lf.txt"}
@{character = "a`r`nb`r`n"; testname = "CRLF-terminated files"; filename = "crlf.txt"}
@{character = "a`nb"; testname = "LF-separated files without trailing newline"; filename = "lf-nt.txt"}
@{character = "a`r`nb"; testname = "CRLF-separated files without trailing newline"; filename = "crlf-nt.txt"}
) {
param ($character, $filename)
Set-Content -Encoding Ascii -NoNewline "$TestDrive\$filename" -value $character
Get-Content -Raw "$TestDrive\$filename" | Should BeExactly $character
}
}