From f4ae69a90538e0ef7a8ae568f194e611e75ef34b Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sat, 30 May 2020 10:37:41 -0500 Subject: [PATCH] fixup! Recover from bad redirections in the middle of a job pipeline Fix inadvertent early abort (thanks, nested switch-in-for-loop!) that led to subsequent shell input being broken. --- src/io.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/io.cpp b/src/io.cpp index dd71e6714..28186f1ae 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -227,6 +227,7 @@ void io_chain_t::append(const io_chain_t &chain) { } bool io_chain_t::append_from_specs(const redirection_spec_list_t &specs, const wcstring &pwd) { + bool have_error = false; for (const auto &spec : specs) { switch (spec.mode) { case redirection_mode_t::fd: { @@ -257,14 +258,15 @@ bool io_chain_t::append_from_specs(const redirection_spec_list_t &specs, const w // and return false. This lets execution potentially recover and at least gives // the shell a chance to gracefully regain control of the shell (see #7038). this->push_back(make_unique(spec.fd)); - return false; + have_error = true; + break; } this->push_back(std::make_shared(spec.fd, std::move(file))); break; } } } - return true; + return !have_error; } void io_chain_t::print() const {