Do not always collapse space between parameter and value for native arguments. (#17708)

This commit is contained in:
James Truher [MSFT]
2022-07-18 17:51:51 -07:00
committed by GitHub
parent b6a619099b
commit bfb59f1acf
2 changed files with 19 additions and 1 deletions
@@ -165,7 +165,17 @@ namespace System.Management.Automation
{
if (argument != parameter.ParameterText)
{
_argumentList.Add(parameter.ParameterText + argument);
// Only combine the text and argument if there was no space after the parameter,
// otherwise, add the parameter and arguments as separate elements.
if (parameter.SpaceAfterParameter)
{
_argumentList.Add(parameter.ParameterText);
_argumentList.Add(argument);
}
else
{
_argumentList.Add(parameter.ParameterText + argument);
}
}
}
else
@@ -239,6 +239,14 @@ foreach ( $argumentListValue in "Standard","Legacy","Windows" ) {
$lines[1] | Should -BeExactly "Arg 1 is <com:port=\\devbox\pipe\debug,pipe,resets=0,reconnect>"
}
It "Should handle when the ':' is the parameter value" {
$lines = testexe -echoargs awk -F: '{print $1}'
$lines.Count | Should -Be 3
$lines[0] | Should -BeExactly 'Arg 0 is <awk>'
$lines[1] | Should -BeExactly 'Arg 1 is <-F:>'
$lines[2] | Should -BeExactly 'Arg 2 is <{print $1}>'
}
It "Should handle DOS style arguments" {
$lines = testexe -echoargs /arg1 /c:"a string"
$lines.Count | Should -Be 2