-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
Description
-ArgumentList (-Args) currently requires that a non-empty array be passed, which is inconvenient in scenarios where you want to pass arguments through, whether any were specified or not, such as via $Args.
An empty array or a null collection ([System.Management.Automation.Internal.AutomationNull]::Value) should be accepted and should be interpreted as "no arguments to pass".
Currently, passing $Args through in a function is cumbersome; imagine a function wpsh whose purpose is to invoke a Windows PowerShell window from PowerShell Core, with any arguments passed through:
function wpsh {
# Pass all arguments through.
# To do this in a single Start-Process call, you need a cumbersome workaround
# via an aux. hashtable and splatting.
# Ideally,
# Start-Process (Get-Command powershell.exe).Path -Args $Args
# should work directly.
$htArgs = if ($Args.Count) { @{ Args = $Args } } else { @{} }
Start-Process (Get-Command powershell.exe).Path @htArgs
}Steps to reproduce
# Or: [System.Management.Automation.Internal.AutomationNull]::Value, such as produced by `& {}`
$arguments = @()
Start-Process code -Args $argumentsExpected behavior
code (the Visual Studio CLI, if installed) should open / activate, with no arguments being passed.
Actual behavior
Invocation fails with the following error message:
Start-Process : Cannot validate argument on parameter 'ArgumentList'.
The argument is null, empty, or an element of the argument collection contains a null value.
Supply a collection that does not contain any null values and then try the command again.
Environment data
PowerShell Core v6.0.0-beta.5 on macOS 10.12.6
PowerShell Core v6.0.0-beta.5 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.0-beta.5 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.483 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)ZSkycat
Metadata
Metadata
Assignees
Labels
Committee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module