-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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:
Negative values cause the cmdlet to return the entire contents.
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
PS> Get-Content ${filePath} -Wait -Tail -1
<full content of the file at ${filePath} shown here>Observed behavior
PS> Get-Content ${filePath} -Wait -Tail -1
Get-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.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 says Get-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.