Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

New-Item: When creating symbolic links (symlinks) / reparse points, the -Target path should always be treated as a *literal* path #13136

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

Note:

Summary of the new feature/enhancement

When you create a symlink or reparse point, you want to target a specific, literal target path - you're not looking for this path to determined via wildcard-pattern matching, which, however, is what currently happens: a -Target (-Value) argument is (invariably) interpreted as a wildcard pattern. What makes the behavior even less useful is that the pattern must resolve to exactly one path.

  • Interpreting the -Target (-Value) argument as a wildcard expression means that meant-to-be-literal paths such as [a].txt would mistakenly target a.txt, if present, for instance.

  • Also, as a potentially unwanted side effect, if the -Target (-Value) is determined via wildcard resolution, a relative input path (pattern) is invariably resolved to a full path.

The sensible behavior is to always treat the -Target (-Value) argument as a literal path (and to preserve its relative-vs.-full path status, as specified).


Once the change is implemented, the following tests - which currently fail - should succeed:

$null = New-Item 'file1', 'file[1]'

$targetRelative = 'file[1]'
$targetAbsolute = Join-Path $pwd.providerpath 'file[1]'

(New-Item -Type SymbolicLink fileL -Target $targetRelative).Target | Should -Be $targetRelative
(New-Item -Force -Type SymbolicLink fileL -Target $targetAbsolute).Target | Should -Be $targetAbsolute

The tests currently fail, because file[1] is interpreted as a wildcard pattern that happens to match file1.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIn-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.