Title: Get-Content -ReadCount 0 does not respect -TotalCount · Issue #10707 · PowerShell/PowerShell · GitHub
Open Graph Title: Get-Content -ReadCount 0 does not respect -TotalCount · Issue #10707 · PowerShell/PowerShell
X Title: Get-Content -ReadCount 0 does not respect -TotalCount · Issue #10707 · PowerShell/PowerShell
Description: Get-Content -ReadCount 0 is 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 ...
Open Graph Description: Get-Content -ReadCount 0 is 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 ...
X Description: Get-Content -ReadCount 0 is 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 ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/10707
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Get-Content -ReadCount 0 does not respect -TotalCount","articleBody":"`Get-Content -ReadCount 0` is 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.\r\nIf the intent is to read all lines into memory anyway, this can greatly speed up the command.\r\n\r\n`-TotalCount \u003cn>` allows you to limit the overall number of lines to be read from the file to a given number.\r\n\r\nIt's reasonable to expect that `-ReadCount 0` also respects that number and therefore returns an `\u003cn>`-element array.\r\n\r\nCurrently, `-ReadCount 0` effectively _ignores_ `-TotalCount` and always returns _all_ lines in the file as an array.\r\n\r\nBy contrast, a specific number - e.g, `-ReadCount 2` to read the file as a stream of 2-element arrays - _does_ respect `-TotalCount`.\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n1..10 > temp:/$pid.txt\r\n\r\n(Get-Content temp:/$pid.txt -TotalCount 3 -ReadCount 0).Count | Should -Be 3\r\n\r\nRemove-Item temp:/$pid.txt\r\n```\r\n\r\n# Expected behavior\r\n\r\nThe test should pass.\r\n\r\n# Actual behavior\r\n\r\nThe test fails:\r\n\r\n```none\r\nExpected 3, but got 10.\r\n```\r\n\r\nThat is, all 10 lines were read, even though only 3 were requested with `-TotalCount`\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core 7.0.0-preview.4\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-10-05T02:33:03Z","url":"https://github.com/PowerShell/PowerShell/issues/10707"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f48ad288-d63b-0528-b0ba-580d47194575 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1C0:267B64:BD5C5E:1069382:6AFD44CF |
| html-safe-nonce | b574490af1eef9d80161a832f619b4ebed65129b923fc80d45251d4a9b4e1744 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUMwOjI2N0I2NDpCRDVDNUU6MTA2OTM4Mjo2QUZENDRDRiIsInZpc2l0b3JfaWQiOiIzMDM1OTI0MDEwMzY2NzQ3ODU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 73aac25e5b628bdb9d318bd2e12b12d18be2aa667c18e188a01e68ddb023ac26 |
| hovercard-subject-tag | issue:502905414 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/10707/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8d64bfd07a4f3dbc86cf7aa5a30fa30a15f258710a074cc23d046850c23bb58d/PowerShell/PowerShell/issues/10707 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8d64bfd07a4f3dbc86cf7aa5a30fa30a15f258710a074cc23d046850c23bb58d/PowerShell/PowerShell/issues/10707 |
| og:image:alt | Get-Content -ReadCount 0 is 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width