-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Milestone
Description
Steps to reproduce
Save the following to t.Tests.ps1 and invoke with ./t.Tests.ps1:
Describe "Get-Content -Raw test" {
BeforeAll {
Push-Location TestDrive:/
$lfTextUnterminated = "a`nb"
$lfText = "a`nb`n"
$crlfTextUnterminated = "a`r`nb"
$crlfText = "a`r`nb`r`n"
Set-Content -Encoding Ascii -NoNewline 'lf.txt' -value $lfText
Set-Content -Encoding Ascii -NoNewline 'crlf.txt' -value $crlfText
Set-Content -Encoding Ascii -NoNewline 'lf-nt.txt' -value $lfTextUnterminated
Set-Content -Encoding Ascii -NoNewline 'crlf-nt.txt' -value $crlfTextUnterminated
}
It "Reads LF-terminated files in full." {
Get-Content -Raw 'lf.txt' | Should BeExactly $lfText
}
It "Reads CRLF-terminated files in full." {
Get-Content -Raw 'crlf.txt' | Should BeExactly $crlfText
}
It "Reads LF-separated files without trailing newline in full." {
Get-Content -Raw 'lf-nt.txt' | Should BeExactly $lfTextUnterminated
}
It "Reads CRLF-separated files without trailing newline in full." {
Get-Content -Raw 'crlf-nt.txt' | Should BeExactly $crlfTextUnterminated
}
AfterAll {
Remove-Item -LiteralPath 'lf.txt', 'lf-nt.txt', 'crlf.txt', 'crlf-nt.txt'
Pop-Location
}
}Expected behavior
All tests should pass.
Actual behavior
The files ending in an LF character are read without that last character.
Note that Windows Powershell is not affected.
...
[-] Reads LF-terminated files in full. 47ms
Expected string length 4 but was 3. Strings differ at index 3.
Expected: {a\nb\n}
But was: {a\nb}
---------------^
at line: 18 in /Users/mklement/Desktop/pg/t.Tests.ps1
18: Get-Content -Raw 'lf.txt' | Should BeExactly $lfText
[-] Reads CRLF-terminated files in full. 20ms
Expected string length 6 but was 5. Strings differ at index 5.
Expected: {a\r\nb\r\n}
But was: {a\r\nb\r}
-------------------^
at line: 21 in /Users/mklement/Desktop/pg/t.Tests.ps1
21: Get-Content -Raw 'crlf.txt' | Should BeExactly $crlfText
...
Environment data
PowerShell Core v6.0.0-beta.7 on macOS 10.12.6
PowerShell Core v6.0.0-beta.7 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0-beta.7 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.built-in PowerShell providers such as FileSystem, Certificates, Registry, etc.