-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Get-Content -ReadCount 0 does not respect -TotalCount #10707
Copy link
Copy link
Closed
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-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.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
Metadata
Metadata
Assignees
Labels
HacktoberfestPotential candidate to participate in HacktoberfestPotential candidate to participate in HacktoberfestIssue-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.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
Get-Content -ReadCount 0is a convenient way to request that all lines be read at once, into an array and to have that array be output as a single object to the success stream.If the intent is to read all lines into memory anyway, this can greatly speed up the command.
-TotalCount <n>allows you to limit the overall number of lines to be read from the file to a given number.It's reasonable to expect that
-ReadCount 0also respects that number and therefore returns an<n>-element array.Currently,
-ReadCount 0effectively ignores-TotalCountand always returns all lines in the file as an array.By contrast, a specific number - e.g,
-ReadCount 2to read the file as a stream of 2-element arrays - does respect-TotalCount.Steps to reproduce
Expected behavior
The test should pass.
Actual behavior
The test fails:
That is, all 10 lines were read, even though only 3 were requested with
-TotalCountEnvironment data