-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negative values provided to the Get-Content
-Tail
parameter no longer return the entire content, and instead print an error
#21347
Comments
Just to put in perspective
so that is 2,147,483,647 There are only 783,137 words in the King James bible and the Linux kernel is of the order of 30 million lines across all files. |
Still, if almost every character is a line break, that's only a 2 GiB file. I have dealt with logs in the hundreds of gigabytes before, and introducing an arbitrary limitation when there previously wasn't one is a regression, regardless of perspective. Also, the behavior not matching the documentation is itself an issue. |
The fact is that there's a regression and the behavior doesn't match the documentation. That's the purpose of the report. Please stop commenting on this issue if the comments are not intended to further the issue's resolution. Edit: There was a comment above this after my previous comment, but it seems to have been deleted. |
The change was made here: #19715 looking at the old code it seems that there was never any reason to specify a negative number because if you did then it would just read it from start to finish, as if you hadn't specified
The answer seems to be to just not specify |
OK, thanks. I've tested that, and it does seem to work as desired. I'll update my command to omit It sounds like the resolution for this issue, then, is to update the documentation to remove the reference to using a negative value, and possibly suggest omitting |
The documentation change does not suggest omitting |
I already gave my feedback in the ticket. If someone cares about it, they can read the ticket. |
Prerequisites
Steps to reproduce
Negative values for
Get-Content
parameter-Tail
are no longer considered valid, despite the documentation specifying that the accepted type is Int32 which supports negative values, and that providing a negative value results in an unlimited number of lines, effectively showing the full content of the file regardless of its length, even if that length is above$([int]::MaxValue)
.The latest documentation for this command says this in the
-Tail
section:So, it looks like the current behavior does not match the documented behavior.
I see no current equivalent way to guarantee getting a truly unlimited number of lines beyond
$([int]::MaxValue)
. That returns a very large number, but does not guarantee all lines if the file has more lines than$([int]::MaxValue)
.Expected behavior
Observed behavior
Error details
I am submitting this issue report on a different computer from the one in which I discovered this issue, so I don't have direct copy access to the output of
Get-Error
. The error saysGet-Content: Cannot validate argument on parameter 'Tail'. The -1 argument is less than the minimum allowed range of 0. Supply an argument that is greater than or equal to 0 and then try the command again.
though.Environment data
I am submitting this issue report on a different computer from the one in which I discovered this issue, so I don't have direct copy access to the output of ${PSVersionTable}. It says the version is
7.4.1
though.The text was updated successfully, but these errors were encountered: