-
Notifications
You must be signed in to change notification settings - Fork 7.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set $? correctly for command expression with redirections #16046
Conversation
Do we already have regression tests verifying that the |
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. |
@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
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.