From f3d31f6ef6997a47e3ae34bf454144be90b5d7b5 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Tue, 28 Apr 2020 09:43:34 -0700 Subject: [PATCH] Introduce out_is_piped and err_is_piped on io_streams_t builtin_eval needs to know whether to set up bufferfills to capture its output and/or errput; it should do this specifically if the output and errput is piped (and not, say, directed to a file). In preparation for this change, add bools to io_streams_t which track whether stdout and stderr are specifically piped. --- src/exec.cpp | 11 +++++++++-- src/io.h | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index bd24f5281..1557caf0b 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -428,9 +428,16 @@ static bool exec_internal_builtin_proc(parser_t &parser, const std::shared_ptrio_mode == io_mode_t::pipe); + streams.err_is_piped = (err_io != nullptr && err_io->io_mode == io_mode_t::pipe); streams.stdin_is_directly_redirected = stdin_is_directly_redirected; streams.io_chain = &proc_io_chain; diff --git a/src/io.h b/src/io.h index ccaa67eb2..39d286e74 100644 --- a/src/io.h +++ b/src/io.h @@ -451,7 +451,12 @@ struct io_streams_t { // < foo.txt bool stdin_is_directly_redirected{false}; - // Indicates whether stdout and stderr are redirected (e.g. to a file or piped). + // Indicates whether stdout and stderr are specifically piped. + // If this is set, then the is_redirected flags must also be set. + bool out_is_piped{false}; + bool err_is_piped{false}; + + // Indicates whether stdout and stderr are at all redirected (e.g. to a file or piped). bool out_is_redirected{false}; bool err_is_redirected{false};