diff --git a/src/System.Management.Automation/engine/MshCommandRuntime.cs b/src/System.Management.Automation/engine/MshCommandRuntime.cs index f9e4b6bae6..cf1260f1fc 100644 --- a/src/System.Management.Automation/engine/MshCommandRuntime.cs +++ b/src/System.Management.Automation/engine/MshCommandRuntime.cs @@ -2381,7 +2381,8 @@ namespace System.Management.Automation // 913088-2005/06/06 // PipelineStoppedException should not get added to $Error // 2008/06/25 - narrieta: ExistNestedPromptException should not be added to $error either - if (!(e is HaltCommandException) && !(e is PipelineStoppedException) && !(e is ExitNestedPromptException)) + // 2019/10/18 - StopUpstreamCommandsException should not be added either + if (!(e is HaltCommandException) && !(e is PipelineStoppedException) && !(e is ExitNestedPromptException) && !(e is StopUpstreamCommandsException)) { try { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 index 872b785049..d04ce8d069 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Select-Object.Tests.ps1 @@ -113,7 +113,12 @@ Describe "Select-Object" -Tags "CI" { $result[0].Size | Should -Be ($orig1 + 1) $dirObject[0].Size | Should -Be ($orig1 + 1) $dirObject[$TestLength].Size | Should -Be ($orig2 + 1) - } + } + + It "Should not leak 'StopUpstreamCommandsException' internal exception for stopping upstream" { + 1,2 | Select-Object -First 1 -ErrorVariable err + $err | Should -BeNullOrEmpty + } } Describe "Select-Object DRT basic functionality" -Tags "CI" {