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-Item finds hidden directories even without -Force when a slash is appended #10292

Open
mklement0 opened this issue Aug 2, 2019 · 0 comments

Comments

@mklement0
Copy link
Contributor

commented Aug 2, 2019

Note: The fact that Get-ChildItem and Get-Item do not find hidden items with literal paths even without -Force - in contrast with other filesystem cmdlets such as Test-Path and Resolve-Path, see #6502 and #6501 - is problematic in itself, but that's the behavior we're stuck with.

This issue is about a particular inconsistency in the context of the current behavior.

Steps to reproduce

On Linux or macOS (does not happen on Windows).

mkdir -p .tf  # create temporary hidden folder
{ Get-Item .tf -EA Stop } | Should -Throw
{ Get-Item .tf/ -EA Stop } | Should -Throw
rmdir .tf

Note that GetChild-Item, by contrast, consistently finds hidden directories by literal path even without -Force, with or without a trailing / - arguably, another inconsistency.

Expected behavior

No output, because both tests should pass, given that hidden dir. .tf shouldn't be found without -Force, with or without trailing /.

Actual behavior

Expected an exception, to be thrown, but no exception was thrown.

That is, the second command targeting .tf with a trailing / unexpectedly succeeded (found the item).

Environment data

PowerShell Core v7.0.0-preview.2 (7.0.0-preview.2) on macOS 10.14.6
PowerShell Core v7.0.0-preview.2 (7.0.0-preview.2) on Ubuntu 18.04.2 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.