Skip to content
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

Get-ChildItem -Recurse shouldn't quietly ignore -Include and -Exclude when -LiteralPath is used instead of -Path #3730

Closed
mklement0 opened this issue May 8, 2017 · 2 comments · Fixed by #5462
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-Fixed The issue is fixed. WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module

Comments

@mklement0
Copy link
Contributor

mklement0 commented May 8, 2017

Even without using wildcards, Get-ChildItem -Recurse allows matching items on every level of the target hierarchy, possibly filtered with -Include and -Exclude.

However, if you use -LiteralPath rather than the (implied) -Path parameter, -Include and -Exclude are quietly ignored:

If there's a good reason for this behavior (none that I'm aware of), then at the very least a warning about -Include / -Exclude getting ignored should be issued, or a separate parameter set should prevent combining -LiteralPath with -Include / -Exclude.

Steps to reproduce

Get-ChildItem              $PSHOME -Recurse -Exclude *   # implies -Path $PSHOME
Get-ChildItem -LiteralPath $PSHOME -Recurse -Exclude *

Expected behavior

Both calls should yield no output, because all items should be excluded by virtue of -Exclude *.

Actual behavior

The 2nd command, due to -Exclude * getting ignored, outputs the entire subtree of $PSHOME.

Environment data

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)
@iSazonov iSazonov added WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif labels May 8, 2017
@SteveL-MSFT
Copy link
Member

This appears to be a regression from v5 (repros with v5.1)

@nightroman
Copy link

nightroman commented Nov 1, 2017

This appears to be a regression from v5 (repros with v5.1)

From my observations, -Include worked as expected in PS v5 Preview. So something changed exactly in v5 Preview -> v5 RTM.

I have no data about -Exclude (i.e. regression or not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion the issue may not have a clear classification yet. The issue may generate an RFC or may be reclassif Resolution-Fixed The issue is fixed. WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants