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 @@ -87,7 +87,7 @@ protected override void ProcessRecord()
return;
}

if (TotalCount == 0 || Tail == 0)
if (TotalCount == 0)
{
// Don't read anything
return;
Expand Down Expand Up @@ -118,7 +118,7 @@ protected override void ProcessRecord()
// as reading forwards. So we read forwards in this case.
// If Tail is positive, we seek the right position. Or, if the seek failed
// because of an unsupported encoding, we scan forward to get the tail content.
if (Tail > 0)
if (Tail >= 0)
{
bool seekSuccess = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,16 @@ Describe "Get-Content" -Tags "CI" {
Get-Content -Path $testPath -Tail 0 | Should -BeNullOrEmpty
}

It "Should wait for content when using -Tail 0 and -Wait" {
$testValues = @(1,2,3)
$Job = Start-Job -ScriptBlock {Get-Content -Path $using:testPath -Tail 0 -Wait}
Start-Sleep -Seconds 3
Add-Content -Value $testValues -Path $testPath
Start-Sleep -Seconds 3
Compare-Object -ReferenceObject $testValues -DifferenceObject ($Job | Receive-Job) | Should -BeNullOrEmpty
$Job | Remove-Job -Force
}

It "Should throw TailAndHeadCannotCoexist when both -Tail and -TotalCount are used" {
{
Get-Content -Path $testPath -Tail 1 -TotalCount 1 -ErrorAction Stop
Expand Down