Set-Location ~
Get-ChildItem . -Depth 0 | Measure-Object
Get-ChildItem . -Depth 0 -Include * | Measure-Object
Get-ChildItem . -Depth 0 -Exclude NoSuchItemImSure | Measure-Object
All 3 commands should output the same number - the count of items in the current dir.
The 1st command reports the number of items in the current directory only.
The 2nd and 3rd commands unexpectedly traverse the entire subtree, ignoring -Depth 0.
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on macOS 10.12.4
PowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Microsoft Windows 10 Pro (64-bit; v10.0.14393)
Given that I spent longer than I care to admit being tripped up by this this morning, I figure it couldn't hurt to add a comment on this issue in support of sorting it.
To my mind I see two potential courses of action:
I'd say the second one is more desirable, but I'm approaching this from a high-level as a user so I don't fully appreciate the amount of work or if it would result in any breaking changes.
The same behavior in 5.1.15063.608.
Get-ChildItem -Depth 0 -Filter 'mask' works good, but
Get-ChildItem -Depth 0 -Include 'mask' returns all 'mask' elemens of tree.
Most helpful comment
Given that I spent longer than I care to admit being tripped up by this this morning, I figure it couldn't hurt to add a comment on this issue in support of sorting it.
To my mind I see two potential courses of action:
I'd say the second one is more desirable, but I'm approaching this from a high-level as a user so I don't fully appreciate the amount of work or if it would result in any breaking changes.