mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
Read exit status before failing in failed read from stdout pipe (#1723)
This commit is contained in:
parent
7ce8026916
commit
27fdef5479
@ -339,16 +339,27 @@ fn spawn(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(e) => {
|
||||||
let _ = stdout_read_tx.send(Ok(Value {
|
// If there's an exit status, it makes sense that we may error when
|
||||||
value: UntaggedValue::Error(ShellError::labeled_error(
|
// trying to read from its stdout pipe (likely been closed). In that
|
||||||
"Unable to read from stdout.",
|
// case, don't emit an error.
|
||||||
"unable to read from stdout",
|
let should_error = match child.wait() {
|
||||||
&stdout_name_tag,
|
Ok(exit_status) => !exit_status.success(),
|
||||||
)),
|
Err(_) => true,
|
||||||
tag: stdout_name_tag.clone(),
|
};
|
||||||
}));
|
|
||||||
break;
|
if should_error {
|
||||||
|
let _ = stdout_read_tx.send(Ok(Value {
|
||||||
|
value: UntaggedValue::Error(ShellError::labeled_error(
|
||||||
|
format!("Unable to read from stdout ({})", e),
|
||||||
|
"unable to read from stdout",
|
||||||
|
&stdout_name_tag,
|
||||||
|
)),
|
||||||
|
tag: stdout_name_tag.clone(),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -358,10 +369,7 @@ fn spawn(
|
|||||||
// than what other shells will do.
|
// than what other shells will do.
|
||||||
let external_failed = match child.wait() {
|
let external_failed = match child.wait() {
|
||||||
Err(_) => true,
|
Err(_) => true,
|
||||||
Ok(exit_status) => match exit_status.code() {
|
Ok(exit_status) => !exit_status.success(),
|
||||||
Some(e) if e != 0 => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if external_failed {
|
if external_failed {
|
||||||
|
Loading…
Reference in New Issue
Block a user