Skip to content

Get-ChildItem will recurse indefinititely for recursive symlinks #1875

@DHowett

Description

@DHowett

Steps to reproduce

gci -r /sys

Expected behavior

gci reaches its terminus, and then ceases

Actual behavior

Because of these recursive symlinks,

PS /> ls -la /sys/bus/cpu/devices/cpu0/
lrwxrwxrwx.  1 root root    0 Aug 18 16:12 node0 -> ../../node/node0
PS /> ls -la /sys/bus/cpu/devices/cpu0/node0/
lrwxrwxrwx. 1 root root    0 Aug 18 16:12 cpu0 -> ../../cpu/cpu0

gci eventually runs into something like this:


    Directory: /sys/bus/cpu/devices/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/nod
    e0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0/node0/cpu0


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       08/18/2016     16:13                cache

It has shown no sign of stopping.

Linux's equivalent ls -lR /sys will cease, as it will not descend into already visited nodes.

Environment data

Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.9
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions