Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private void AppendOneNativeArgument(ExecutionContext context, CommandParameterI
}
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))
Expand All @@ -331,7 +331,7 @@ private void AppendOneNativeArgument(ExecutionContext context, CommandParameterI
}
}
}
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Describe "Will error correctly if an attempt to set variable to improper value"
}
}

foreach ( $argumentListValue in "Standard","Legacy" ) {
foreach ( $argumentListValue in "Standard","Legacy","Windows" ) {
$PSNativeCommandArgumentPassing = $argumentListValue
Describe "Native Command Arguments (${PSNativeCommandArgumentPassing})" -tags "CI" {
# When passing arguments to native commands, quoted segments that contain
Expand Down Expand Up @@ -263,6 +263,28 @@ foreach ( $argumentListValue in "Standard","Legacy" ) {
$lines[$i] | Should -BeExactly "Arg $i is <$($expected[$i])>"
}
}

It "Should handle empty args correctly (ArgumentList=${PSNativeCommandArgumentPassing})" {
if ($PSNativeCommandArgumentPassing -eq 'Legacy') {
$expectedLines = 2
}
else {
$expectedLines = 3
}

$lines = testexe -echoargs 1 '' 2
$lines.Count | Should -Be $expectedLines
$lines[0] | Should -BeExactly 'Arg 0 is <1>'

if ($expectedLines -eq 2) {
$lines[1] | Should -BeExactly 'Arg 1 is <2>'
}
else {
$lines[1] | Should -BeExactly 'Arg 1 is <>'
$lines[2] | Should -BeExactly 'Arg 2 is <2>'
}

}
}
}
Describe 'PSPath to native commands' -tags "CI" {
Expand Down