Repository navigation
Set $? correctly for command expression with redirections - #16046
Conversation
|
Do we already have regression tests verifying that the |
|
Ilya (@iSazonov) Thanks for adding the needed labels! |
|
The change that (seemingly) caused this one to crop up was the change for So I guess a test case would be: function fail {
[CmdletBinding()]
param()
try { throw } catch { $PSCmdlet.WriteError($_) }
}
fail
$? | Should -BeFalse
(fail)
$? | Should -BeFalse |
|
Backport rejected as this does not meet the bar. This will cause a change in behavior for 7.0.x and 7.1.x. |
|
Rain Sallow (/u/ta11ow) (@vexx32) It still behaves as expected, but I don't know if we have such test already. I can add one if not. |
|
🎉 Handy links: |

PR Summary
Fix #16033
This PR makes a small update to
ShouldSetExecutionStatusToSuccess(PipelineAst)to not exclude single expression with redirections, so that$?can be set to true properly for single-element pipeline that only contains a command expression with redirections.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.