Skip to content

Get-Content -Tail parameter is broken in v7.1.0-rc.2 and v7.1.0 #14028

Closed

Description

@FatalBulletHit

Steps to reproduce

Run the following with the latest preview version (7.1.0-rc.2) or the latest release version (7.1.0) of PowerShell 7:

(Get-ChildItem $PSHOME -File).Count
(Get-ChildItem $PSHOME -File | ForEach-Object { Get-Content $_.FullName -Tail 1 }).Count

Expected behavior

Output

449
449

Works as intended in the previous release version (7.0.3).

Actual behavior

Output

449
26

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.0-rc.2
PSEdition                      Core
GitCommitId                    7.1.0-rc.2
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Question
    on Nov 10, 2020
  2. iSazonov commented on Nov 11, 2020

    @iSazonov
    Collaborator

    Please create more simple repro steps with one file.

  3. FatalBulletHit commented on Nov 11, 2020

    @FatalBulletHit
    Author

    Made it even simpler I guess and if you need a reference file, just use the Accessibility.dll from the PowerShell 7 installation directory or download it: Accessibility.dll.txt

    I'm fairly sure the issue has something to do with special characters, shouldn't be down to my system either as I was able to reproduce it in a VM.

  4. vexx32 commented on Nov 11, 2020

    @vexx32
    Collaborator

    FatalBulletHit what version have you seen this working correctly in?

  5. FatalBulletHit commented on Nov 11, 2020

    @FatalBulletHit
    Author

    I used the latest release, 7.0.3 that'd be.
    Looking at the history of GetContentCommand.cs I'd assume it might be this or this commit.

  6. vexx32 commented on Nov 11, 2020

    @vexx32
    Collaborator

    Hm... doesn't look like it's either of those.

    I think it's here: d528bf5#diff-0cf19feadd29d19fb01dcfe57f5fd9bd24be0d5fed7c1241f0cfa05da14c2fc1

  7. FatalBulletHit commented on Nov 11, 2020

    @FatalBulletHit
    Author

    The bug is also present in the latest 7.1.0 release.

  8. changed the title [-]Get-Content -Tail parameter is broken in latest preview version[/-] [+]Get-Content -Tail parameter is broken in v7.1.0-rc.2 and v7.1.0[/+] on Nov 11, 2020
  9. kvprasoon commented on Nov 12, 2020

    @kvprasoon
    Contributor

    for a better picture

    $count=0;(Get-ChildItem $PSHOME -File | ForEach-Object {$count++;[pscustomobject]@{name=$_.FullName;count=$count;content=(Get-Content $_.FullName -Tail 1 )}})
    
  10. iSazonov commented on Nov 12, 2020

    @iSazonov
    Collaborator

    Hm... doesn't look like it's either of those.

    I think it's here: d528bf5#diff-0cf19feadd29d19fb01dcfe57f5fd9bd24be0d5fed7c1241f0cfa05da14c2fc1

    But TotalCount default is -1.

  11. iSazonov commented on Nov 12, 2020

    @iSazonov
    Collaborator

    I see the issue in PowerShell 7.1.0-preview.1
    Maybe #11899?

  12. added
    Issue-Bug
    and removed
    Issue-Question
    on Nov 12, 2020
  13. added
    Resolution-No Activity
    on Nov 16, 2023
  14. Liturgist commented on Nov 16, 2023

    @Liturgist

    Still the same result.

    PS C:\> $psversionTable.psversion.ToString()
    7.3.9
    PS C:\> (Get-ChildItem $PSHOME -File).Count
    >> (Get-ChildItem $PSHOME -File | ForEach-Object { Get-Content $_.FullName -Tail 1 }).Count
    323
    29
    
  15. Liturgist commented on Nov 18, 2023

    @Liturgist

    Still the same result. Are the binary .dll files in $PSHOME omitted?

    PS C:\> $PSVersionTable.PSVersion.ToString()
    7.4.0
    PS C:\> (Get-ChildItem $PSHOME -File).Count
    323
    PS C:\> (Get-ChildItem $PSHOME -File | ForEach-Object { Get-Content $_.FullName -Tail 1 }).Count
    29
    
  16. microsoft-github-policy-service commented on Nov 26, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugResolution-No ActivityWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions