From d51b5fdc3087b6eaee1107f76e480027eb4545b4 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 7 Jan 2019 13:39:57 -0800 Subject: [PATCH] `help` function shouldn't use pager for AliasHelpInfo (#8552) --- .../engine/InitialSessionState.cs | 5 +++-- test/powershell/engine/Help/HelpSystem.Tests.ps1 | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index a0f0dde001..6e40cacd2b 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4169,8 +4169,9 @@ param( $help = Get-Help @PSBoundParameters - # If a list of help is returned, don't pipe to more - if (($help | Select-Object -First 1).PSTypeNames -Contains 'HelpInfoShort') + # If a list of help is returned or AliasHelpInfo (because it is small), don't pipe to more + $psTypeNames = ($help | Select-Object -First 1).PSTypeNames + if ($psTypeNames -Contains 'HelpInfoShort' -Or $psTypeNames -Contains 'AliasHelpInfo') { $help } diff --git a/test/powershell/engine/Help/HelpSystem.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.Tests.ps1 index 10654c8a62..a9a59f5abc 100644 --- a/test/powershell/engine/Help/HelpSystem.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.Tests.ps1 @@ -339,7 +339,10 @@ Describe "Get-Help should find pattern help files" -Tags "CI" { } Describe "Get-Help should find pattern alias" -Tags "CI" { - # Remove test alias + BeforeAll { + Set-Alias -Name testAlias1 -Value Where-Object + } + AfterAll { Remove-Item alias:\testAlias1 -ErrorAction SilentlyContinue } @@ -355,11 +358,16 @@ Describe "Get-Help should find pattern alias" -Tags "CI" { } It "Get-Help should find alias with * pattern" { - Set-Alias -Name testAlias1 -Value Where-Object $help = Get-Help testAlias1* $help.Category | Should -BeExactly "Alias" $help.Synopsis | Should -BeExactly "Where-Object" } + + It "Help alias should be same as Get-Help alias" { + $help1 = Get-Help testAlias* + $help2 = help testAlias* + Compare-Object $help1 $help2 | Should -BeNullOrEmpty + } } Describe "help function uses full view by default" -Tags "CI" {