mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-30 14:53:11 +00:00
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.
This commit is contained in:
parent
b2fa5de54d
commit
f3d31f6ef6
2 changed files with 15 additions and 3 deletions
11
src/exec.cpp
11
src/exec.cpp
|
@ -428,9 +428,16 @@ static bool exec_internal_builtin_proc(parser_t &parser, const std::shared_ptr<j
|
|||
}
|
||||
}
|
||||
|
||||
// Pull out the IOs for stdout and stderr.
|
||||
auto out_io = proc_io_chain.io_for_fd(STDOUT_FILENO);
|
||||
auto err_io = proc_io_chain.io_for_fd(STDERR_FILENO);
|
||||
|
||||
// Set up our streams.
|
||||
streams.stdin_fd = local_builtin_stdin;
|
||||
streams.out_is_redirected = proc_io_chain.io_for_fd(STDOUT_FILENO) != nullptr;
|
||||
streams.err_is_redirected = proc_io_chain.io_for_fd(STDERR_FILENO) != nullptr;
|
||||
streams.out_is_redirected = out_io != nullptr;
|
||||
streams.err_is_redirected = err_io != nullptr;
|
||||
streams.out_is_piped = (out_io != nullptr && out_io->io_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;
|
||||
|
||||
|
|
7
src/io.h
7
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};
|
||||
|
||||
|
|
Loading…
Reference in a new issue