-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix Rename-Item to allow Unix globbing patterns inpaths (#2799) #3661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add -Path in all places wherever flowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
What about |
|
@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! |
|
@iSazonov OK, I've updated the PR description to include a note about |
|
@jeffbi Many thanks! LGTM. |
SteveL-MSFT
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.