You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SubExpression with external command failure does not stop command running #7690
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 a RawStream instead of None
Nu tries to catch external stream exit status, but returns failure = false because above rawstream output
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
I know you mentioned part of this in that issue, however, I could not reproduce the original #7653 . I left some investigations in this one, but feel free to close or associate it.
Activity
Kangaxx-0 commentedon Jan 6, 2023
Wants some insight to get this addressed in a clean fashion
rgwood commentedon Jan 6, 2023
Is this a duplicate of #7653?
Kangaxx-0 commentedon Jan 6, 2023
I know you mentioned part of this in that issue, however, I could not reproduce the original #7653 . I left some investigations in this one, but feel free to close or associate it.
WindSoilder commentedon Jan 6, 2023
It seems that we can't figure out the difference between the them:
Because they all return the same
PipelineData::ExternalStreamwithredirect_stdout: true.But when we run external command in SubExpression,
redirect_stdoutmust be true, so we can catch output and assign result to variable.This is what I get from insight, but sorry that I'm not sure how to fix them properly.
WindSoilder commentedon Feb 23, 2023
Suddenly I know how to solve the problem....We can check the input value after eval the last element in each pipeline..
Revert "Throw out error if external command in subexpression is faile…
Revert "Throw out error if external command in subexpression is faile…