Fix Rename-Item to allow Unix globbing patterns inpaths (#2799) - #3661
Conversation
) In the process of normalizing a relative path, PowerShell checks to see see if the path exists, which it does by invoking Directory.EnumerateFiles(directory, filename); On Unix platforms, if the filename contains globbing patterns, such as [ab], EnumerateFiles (and EnumerateDirectories) will perform the globbing. Using globbing patterns, a file named 'file[txt].txt' is reported as not existing. This fix changes the file-existence test on Unix to use a native function instead of either of the Directory.EnumerateXXX functions.
Ilya (iSazonov)
left a comment
There was a problem hiding this comment.
jeffbi Original Issue say *-Item but the PR fix only Rename-Item. Please add comment about this in the PR description.
| $dirPath = Join-Path $TESTDRIVE "subdir" | ||
| } | ||
| BeforeEach { | ||
| $file = New-Item -ItemType File $filePath -Force |
There was a problem hiding this comment.
Please add -Path in all places wherever flowed.
What about |
|
Ilya (@iSazonov) The issue didn't affect |
|
jeffbi My question was again about addition to the PR description. I expect that this will help make PowerShell documentation more precise. Thanks! |
|
Ilya (@iSazonov) OK, I've updated the PR description to include a note about |
|
jeffbi Many thanks! LGTM. |
…2799) (PowerShell#3661) * Fix Rename-Item to allow Unix globbing patterns in -Literal paths (PowerShell#2799) In the process of normalizing a relative path, PowerShell checks to see see if the path exists, which it does by invoking Directory.EnumerateFiles(directory, filename); On Unix platforms, if the filename contains globbing patterns, such as [ab], EnumerateFiles (and EnumerateDirectories) will perform the globbing. Using globbing patterns, a file named 'file[txt].txt' is reported as not existing. This fix changes the file-existence test on Unix to use a native function instead of either of the Directory.EnumerateXXX functions. * Fix for AppVeyor failure * Changes per code review, and a couple of letter-casing changes.
Fixes #2799
In the process of normalizing a relative path, PowerShell checks to see
see if the path exists, which it does by invoking
Directory.EnumerateFiles(directory, filename);On Unix platforms, if the filename contains globbing patterns, such as
[ab],EnumerateFiles(andEnumerateDirectories) will perform the globbing. Usingglobbing patterns, a file named
file[txt].txtis reported as not existing.This fix changes the file-existence test on Unix to use a native function
instead of either of the Directory.EnumerateXXX functions.
This affects the
Move-Item,Remove-Item,Rename-ItemandCopy-Itemcmdlets. This change does not affect theNew-Itemcmdlet, as it is able to create files with names containing Unix globbing characters.