Fix $PSNativeCommandArgPassing = Windows to handle empty args correctly (#16639)

This commit is contained in:
Steve Lee authored and GitHub committed 2022-01-11 23:21:32 -08:00
1 parent e2f39fa0eb
commit 0f21156dee
2 files changed
+25 -3

No files matched your search

@@ -314,7 +314,7 @@ namespace System.Management.Automation
}
else
{
if (argArrayAst != null && ArgumentPassingStyle == NativeArgumentPassingStyle.Standard)
if (argArrayAst != null && ArgumentPassingStyle != NativeArgumentPassingStyle.Legacy)
{
// We have a literal array, so take the extent, break it on spaces and add them to the argument list.
foreach (string element in argArrayAst.Extent.Text.Split(' ', StringSplitOptions.RemoveEmptyEntries))
@@ -331,7 +331,7 @@ namespace System.Management.Automation
}
}
}
else if (ArgumentPassingStyle == NativeArgumentPassingStyle.Standard && currentObj != null)
else if (ArgumentPassingStyle != NativeArgumentPassingStyle.Legacy && currentObj != null)
{
// add empty strings to arglist, but not nulls
AddToArgumentList(parameter, arg);