Fix Rename-Item to allow Unix globbing patterns inpaths (#2799)#3661
Merged
mirichmo merged 3 commits intoPowerShell:masterfrom May 3, 2017
jeffbi:rename-item-2799
Merged
Fix Rename-Item to allow Unix globbing patterns inpaths (#2799)#3661mirichmo merged 3 commits intoPowerShell:masterfrom jeffbi:rename-item-2799
mirichmo merged 3 commits intoPowerShell:masterfrom
jeffbi:rename-item-2799
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
reviewed
Apr 28, 2017
| $dirPath = Join-Path $TESTDRIVE "subdir" | ||
| } | ||
| BeforeEach { | ||
| $file = New-Item -ItemType File $filePath -Force |
Collaborator
There was a problem hiding this comment.
Please add -Path in all places wherever flowed.
Collaborator
What about |
Author
|
@iSazonov The issue didn't affect |
Collaborator
|
@jeffbi My question was again about addition to the PR description. I expect that this will help make PowerShell documentation more precise. Thanks! |
Author
|
@iSazonov OK, I've updated the PR description to include a note about |
Collaborator
|
@jeffbi Many thanks! LGTM. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.