Skip to content

Commit 83f241d

Browse files
committed
Pass non-string objects through formatting system
1 parent 87c24d8 commit 83f241d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/System.Management.Automation/engine/InitialSessionState.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4788,21 +4788,23 @@ internal static SessionStateAliasEntry[] BuiltInAliases
47884788
$moreCommand = (Get-Command -CommandType Application less | Select-Object -First 1).Definition
47894789
}
47904790
4791-
$process = [System.Diagnostics.Process]::new();
4791+
$process = [System.Diagnostics.Process]::new()
47924792
4793-
$process.StartInfo.FileName = 'C:\Windows\system32\more.com';
4794-
$process.StartInfo.UseShellExecute = $false;
4795-
$process.StartInfo.RedirectStandardInput = $true;
4793+
$process.StartInfo.FileName = 'C:\Windows\system32\more.com'
4794+
$process.StartInfo.UseShellExecute = $false
4795+
$process.StartInfo.RedirectStandardInput = $true
47964796
4797-
$process.Start();
4797+
$null = $process.Start()
47984798
4799-
$streamWriter = $process.StandardInput;
4799+
$streamWriter = $process.StandardInput
48004800
}
48014801
48024802
Process
48034803
{
4804-
if ($Line) {
4804+
if ($Line -is [string]) {
48054805
$streamWriter.WriteLine($Line)
4806+
} else {
4807+
$Line | Out-String | more
48064808
}
48074809
}
48084810
@@ -4814,7 +4816,7 @@ internal static SessionStateAliasEntry[] BuiltInAliases
48144816
}
48154817
} else {
48164818
$streamWriter.Close()
4817-
$process.WaitForExit();
4819+
$process.WaitForExit()
48184820
$process.Close()
48194821
}
48204822
}

0 commit comments

Comments
 (0)