mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Mild refactoring of exec_block_or_func_process
Reduce some code duplication.
This commit is contained in:
parent
399062c219
commit
7b25787e52
1 changed files with 7 additions and 15 deletions
22
src/exec.cpp
22
src/exec.cpp
|
@ -781,23 +781,15 @@ static bool exec_block_or_func_process(parser_t &parser, const std::shared_ptr<j
|
|||
}
|
||||
|
||||
// If we have a block output buffer, populate it now.
|
||||
if (!block_output_bufferfill) {
|
||||
// No buffer, so we exit directly. This means we have to manually set the exit
|
||||
// status.
|
||||
p->completed = 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 {
|
||||
|
|
Loading…
Reference in a new issue