Skip to content

Changes in wildcard expansion logic #6927

Closed

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.

Activity

  1. added
    Issue-Discussion
    on May 24, 2018
  2. adamgauthier commented on May 24, 2018

    @adamgauthier
    Contributor

    I fully agree with what you're saying here, and I thought this would be the original approach to solve my issue, I should have said something about it, thanks for bringing it up.

    I don't think the default behavior should be altered only if there is an exact match, that could bring some unexpected results.

  3. iSazonov commented on May 25, 2018

    @iSazonov
    Collaborator

    Seems #5839 is not right because change whole globbing behavior. I'd revert the PR and use LiteralPath if possible.

  4. iSazonov commented on May 25, 2018

    @iSazonov
    Collaborator

    Bash do globbing by default, has an option to disable globbing in a session and allow escaping. PowerShell has Path and LiteralPath and allow escaping. So we have full parity.

  5. SteveL-MSFT commented on Jun 18, 2018

    @SteveL-MSFT
    Member

    Based on the feedback, I agree we should revert the PR and come with up an alternate solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-DiscussionResolution-FixedWG-Cmdlets

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions