Skip to content

Resolve-Path -Relative: -RelativeBasePath accepts wildcard expressions, reports different results when matched via wildcard #20931

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

Note:

  • I think-RelativeBasePath shouldn't even accept wildcard expressions, so to me the preferable resolution is to simply treat -RelativePath arguments as literal paths. (Currently, a wildcard is accepted, but only if it resolves to exactly one item).

  • Doing so would make the problem at hand go away; if this is decided against, at least the inconsistency below must be fixed.

# Matching with *literal* path.
Resolve-Path System32 -Relative -RelativeBasePath C:\Windows

# Matching the same path *via wildcard*
Resolve-Path System32 -Relative -RelativeBasePath C:\Window[s]

Expected behavior

.\System32
.\System32

Actual behavior

.\System32
..\Windows\System32

That is, even though in both commands C:\Windows was ultimately used as the base path, the wildcard matching resulted in different output.

Error details

No response

Environment data

PowerShell 7.4.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions