-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
Supersedes #4472
In said cmdlets, -Path is declared as [string[]], so these cmdlets are capable of accepting multiple files, if passed an array of paths; ditto for -LiteralPath.
Passing a (single) wildcard expression that itself resolves to multiple files unexpectedly breaks, however.
The culprit may be that ReportMultipleFilesNotSupported() is called, whose purpose is to prevent resolution to multiple paths, but whose use is not appropriate in this case.
Note: Potentially, additional cmdlets are affected - you can find the list of candidates (some of which are definitely not affected) as follows:
gcm -parametername path | ? { $_.parametersets.parameters.parametertype -eq [string[]] }Steps to reproduce
"one,two`nuno,due" > file1.csv
"one,two`nun,deux" > file2.csv
Import-Csv -LiteralPath file1.csv, file2.csv
' vs. '
Import-Csv -Path file[12].csvExpected behavior
one two
--- ---
uno due
un deux
vs.
uno due
un deux
Actual behavior
one two
--- ---
uno due
un deux
vs.
Import-Csv : Cannot perform operation because the path resolved to more than one file. This command cannot operate on multiple files.
At /foo.ps1:21 char:1
+ Import-Csv -Path file[12].csv
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Import-Csv], PSInvalidOperationException
+ FullyQualifiedErrorId : ReadWriteMultipleFilesNotSupported,Microsoft.PowerShell.Commands.ImportCsvCommand
Environment data
PowerShell Core v6.0.2 on macOS 10.13.3
PowerShell Core v6.0.2 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.2 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.674 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module