From 7b25787e526ed35e9816097afc98f92bf47c6708 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 13 Jan 2020 14:28:28 -0800 Subject: [PATCH] Mild refactoring of exec_block_or_func_process Reduce some code duplication. --- src/exec.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index af1819a71..79ab177cd 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -781,23 +781,15 @@ static bool exec_block_or_func_process(parser_t &parser, const std::shared_ptrcompleted = true; - if (p->is_last_in_job) { - parser.set_last_statuses(j->get_statuses()); - } - return true; + std::string buffer_contents; + if (block_output_bufferfill) { + // Remove our write pipe and forget it. This may close the pipe, unless another thread has + // claimed it (background write) or another process has inherited it. + io_chain.remove(block_output_bufferfill); + auto block_output_buffer = io_bufferfill_t::finish(std::move(block_output_bufferfill)); + buffer_contents = block_output_buffer->buffer().newline_serialized(); } - assert(block_output_bufferfill && "Must have a block output bufferfiller"); - // Remove our write pipe and forget it. This may close the pipe, unless another thread has - // claimed it (background write) or another process has inherited it. - io_chain.remove(block_output_bufferfill); - auto block_output_buffer = io_bufferfill_t::finish(std::move(block_output_bufferfill)); - - std::string buffer_contents = block_output_buffer->buffer().newline_serialized(); if (!buffer_contents.empty()) { return run_internal_process(p, std::move(buffer_contents), {} /*errdata*/, io_chain); } else {