Drain and write pipelines in try
This commit is contained in:
parent
4851794c55
commit
69f9bbb4c0
|
@ -47,6 +47,7 @@ impl Command for Try {
|
||||||
call: &Call,
|
call: &Call,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
|
let head = call.head;
|
||||||
// This is compiled specially by the IR compiler. The code here is never used when
|
// This is compiled specially by the IR compiler. The code here is never used when
|
||||||
// running in IR mode.
|
// running in IR mode.
|
||||||
let call = call.assert_ast_call()?;
|
let call = call.assert_ast_call()?;
|
||||||
|
@ -61,16 +62,14 @@ impl Command for Try {
|
||||||
let try_block = engine_state.get_block(try_block);
|
let try_block = engine_state.get_block(try_block);
|
||||||
let eval_block = get_eval_block(engine_state);
|
let eval_block = get_eval_block(engine_state);
|
||||||
|
|
||||||
match eval_block(engine_state, stack, try_block, input) {
|
let result = eval_block(engine_state, stack, try_block, input)
|
||||||
Err(err) => run_catch(err, call.head, catch_block, engine_state, stack, eval_block),
|
.and_then(|pipeline| pipeline.write_to_out_dests(engine_state, stack));
|
||||||
Ok(PipelineData::Value(Value::Error { error, .. }, ..)) => run_catch(
|
|
||||||
*error,
|
match result {
|
||||||
call.head,
|
Err(err) => run_catch(err, head, catch_block, engine_state, stack, eval_block),
|
||||||
catch_block,
|
Ok(PipelineData::Value(Value::Error { error, .. }, ..)) => {
|
||||||
engine_state,
|
run_catch(*error, head, catch_block, engine_state, stack, eval_block)
|
||||||
stack,
|
}
|
||||||
eval_block,
|
|
||||||
),
|
|
||||||
Ok(pipeline) => Ok(pipeline),
|
Ok(pipeline) => Ok(pipeline),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,10 +145,10 @@ impl PipelineData {
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
match (self, stack.stdout()) {
|
match (self, stack.stdout()) {
|
||||||
|
(data, OutDest::Pipe | OutDest::Capture) => return Ok(data),
|
||||||
(PipelineData::ByteStream(stream, ..), stdout) => {
|
(PipelineData::ByteStream(stream, ..), stdout) => {
|
||||||
stream.write_to_out_dests(stdout, stack.stderr())?;
|
stream.write_to_out_dests(stdout, stack.stderr())?;
|
||||||
}
|
}
|
||||||
(data, OutDest::Pipe | OutDest::Capture) => return Ok(data),
|
|
||||||
(PipelineData::Empty, ..) => {}
|
(PipelineData::Empty, ..) => {}
|
||||||
(PipelineData::Value(..), OutDest::Null) => {}
|
(PipelineData::Value(..), OutDest::Null) => {}
|
||||||
(PipelineData::ListStream(stream, ..), OutDest::Null) => {
|
(PipelineData::ListStream(stream, ..), OutDest::Null) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user