From 844ae48dc02154f2b950754159f7d76974a73611 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Tue, 28 Apr 2020 10:54:48 -0700 Subject: [PATCH] Apply code review from #6806 --- src/builtin_eval.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/builtin_eval.cpp b/src/builtin_eval.cpp index aade1fddb..50d0849cd 100644 --- a/src/builtin_eval.cpp +++ b/src/builtin_eval.cpp @@ -27,6 +27,9 @@ int builtin_eval(parser_t &parser, io_streams_t &streams, wchar_t **argv) { new_cmd += argv[i]; } + // Copy the full io chain; we may append bufferfills. + io_chain_t ios = *streams.io_chain; + // If stdout is piped, then its output must go to the streams, not to the io_chain in our // streams, because the pipe may be intended to be consumed by a process which // is not yet launched (#6806). If stdout is NOT redirected, it must see the tty (#6955). So @@ -41,6 +44,7 @@ int builtin_eval(parser_t &parser, io_streams_t &streams, wchar_t **argv) { // We were unable to create a pipe, probably fd exhaustion. return STATUS_CMD_ERROR; } + ios.push_back(stdout_fill); } // Of course the same applies to stderr. @@ -51,13 +55,9 @@ int builtin_eval(parser_t &parser, io_streams_t &streams, wchar_t **argv) { if (!stderr_fill) { return STATUS_CMD_ERROR; } + ios.push_back(stderr_fill); } - // Construct the full io chain, perhaps with our bufferfills appended. - io_chain_t ios = *streams.io_chain; - if (stdout_fill) ios.push_back(stdout_fill); - if (stderr_fill) ios.push_back(stderr_fill); - int status = STATUS_CMD_OK; auto res = parser.eval(new_cmd, ios, streams.parent_pgid); if (res.was_empty) {