-
Notifications
You must be signed in to change notification settings - Fork 2.1k
SubExpression with external command failure does not stop command running #7690
Description
Describe the bug
Say we have a SubExpression (^false;"hello,world!"), the first part of external command returns 1 which is a failure, but nu still prints hello, world!
The issue is in eval_subexpression function, it passes redirect_stdout = true, a few actions happens next:
- When nu returns
ExternalStream, the stdout is aRawStreaminstead ofNone
- Nu tries to catch external stream exit status, but returns failure = false because above
rawstreamoutput
Also, inside the eval_subexpression function, it does not deal with early return if external command fails.
I did try to tweak how redirect_stdout works, my change fixes this one but introduces another bug -> stdout will not be able to redirect anymore, nu choose Stdio:piped() and Stdio::inherit based on edirect_stdout
This seems not a recent regression, I saw the same behavior on 0.68 commit tag
How to reproduce
Run (^false;"hello,world!")
Expected behavior
Do not print hello,world!
Screenshots
No response
Configuration
Clipboard does not work, so pasting a screenshot
Additional context
No response



