Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
allow * to be used in registry path for remove-item #4866
Conversation
SteveL-MSFT
assigned
adityapatwardhan
Sep 19, 2017
SteveL-MSFT
requested a review
from
anmenaga
Sep 19, 2017
SteveL-MSFT
requested review from
adityapatwardhan and
daxian-dbw
as
code owners
Sep 19, 2017
msftclas
added
the
cla-not-required
label
Sep 19, 2017
| @@ -3266,6 +3266,10 @@ protected override void ProcessRecord() | ||
| { | ||
| // not a directory | ||
| } | ||
| + catch (System.ArgumentException) |
anmenaga
Sep 19, 2017
Contributor
Maybe it is better to skip that altogether if provider is not FileSystem provider?
e.g.: resolvedPath.Provider.Name.Equals(FileSystemProvider.ProviderName, StringComparison.OrdinalIgnoreCase)
| @@ -3266,6 +3266,10 @@ protected override void ProcessRecord() | ||
| { | ||
| // not a directory | ||
| } | ||
| + catch (System.ArgumentException) | ||
| + { |
anmenaga
Sep 19, 2017
Contributor
Need to make sure that FileSystem paths continue to work as they were before this new catch handler; 2 tests:
- remove-item with -Path and filesystem path that contains *
- remove-item with -LiteralPath and filesystem path that contains *
SteveL-MSFT
Sep 20, 2017
Owner
Looks like there's tests for -Path, I'll add a test for -LiteralPath with *
SteveL-MSFT
Sep 20, 2017
Owner
Looks like the current code does nothing if you use a * with -literalpath:
remove-item -literalpath .\a*.xmlI'll fix it so it returns error when using -literalpath, but it's a breaking change
| @@ -3266,6 +3266,10 @@ protected override void ProcessRecord() | ||
| { | ||
| // not a directory | ||
| } | ||
| + catch (System.ArgumentException) |
anmenaga
Sep 19, 2017
Contributor
Maybe it is better to skip that altogether if provider is not FileSystem provider?
e.g.: resolvedPath.Provider.Name.Equals(FileSystemProvider.ProviderName, StringComparison.OrdinalIgnoreCase)
| + try { | ||
| + $tempPath = "HKCU:\_tmp" | ||
| + $testPath = "$tempPath\*\sub" | ||
| + New-Item -Force $testPath |
| + $testPath | Should Not Exist | ||
| + } | ||
| + finally { | ||
| + Remove-Item -Recurse $tempPath |
SteveL-MSFT
added
Breaking-Change
Review - Committee
Committee-Reviewed
and removed
Review - Committee
labels
Sep 20, 2017
|
@PowerShell/powershell-committee reviewed this and is ok with the minor |
|
@anmenaga Can you have a look again? |
|
@SteveL-MSFT Can you update the PR description. |


SteveL-MSFT commentedSep 19, 2017
•
Edited 1 time
-
SteveL-MSFT
Sep 22, 2017
Code is creating a DirectoryInfo instance to determine if the path is a directory or file, but it fails because
*is not allowed, however,*is a valid character in a registry path. Fix is to catch this exception and ignore it. This means that using-literalpathwith an asterisk and the filesystem provider will now return an error rather than returning quietly.Fix #4704
Fix #4330