Skip to content

Changes in wildcard expansion logic #6927

Closed
@KillyMXI

Description

@KillyMXI

This issue is opened to discuss the change made in #5839 and its possible consequences.
Originally made to fix #5752 (avoid wildcard expansion in working folder path when opening new session), it also has other effects that require more careful evaluation.
(following is the copy of my original comment)

Something with implemented fix still bothers me.
When started playing with v6.1.0-preview.2, I realized that Get-ChildItem is also affected by this change.
And everything else using wildcard expansion now has added complexity - conditional branch with try-catch (what kind of performance overhead it might also have, btw?)

PS C:\ps_test> Get-ChildItem


    Directory: C:\ps_test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       24.05.2018      2:03                [ab]a
d-----       24.05.2018      2:03                aa
d-----       24.05.2018      2:03                ba


PS C:\ps_test> Get-ChildItem [ab]a


    Directory: C:\ps_test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       24.05.2018      2:03                [ab]a


PS C:\ps_test> Get-ChildItem [abc]a


    Directory: C:\ps_test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       24.05.2018      2:03                aa
d-----       24.05.2018      2:03                ba

While this might even make it work as expected more times than before, it has an increased level of surprise. It might make issues caused by the use of -Path instead of -LiteralPath to show up less frequently but will make them harder to trace when they finally show up.
Using wildcards by default and literal path as an option was a major design mistake, imo. This patch makes a step back, but in a way that makes it less predictable. Is it OK to have more "magic"?

I also wonder why the fix was made in this way instead of just calling Set-Location with -LiteralPath when initializing a session? Working folder is by definition a literal path. It would've kept behavior changes to minimum.

Metadata

Metadata

Assignees

Labels

Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions