You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Note:
This is technically a breaking change, but one that to me falls into Bucket 3: Unlikely Grey Area.
We've recently made an analogous change to
Invoke-WebRequest/Invoke-RestMethod, which now sensibly interpret their-OutFileargument invariably as a literal path - see Make-OutFileparam in web cmdlets to work like -LiteralPath #11701Summary 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].txtwould mistakenly targeta.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:
The tests currently fail, because
file[1]is interpreted as a wildcard pattern that happens to matchfile1.