mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 15:50:27 +08: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
96b09a321d
commit
607779257c
11
src/exec.cpp
11
src/exec.cpp
|
@ -416,9 +416,16 @@ static bool exec_internal_builtin_proc(parser_t &parser, process_t *p, const io_
|
|||
}
|
||||
}
|
||||
|
||||
// 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
|
@ -448,7 +448,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 New Issue
Block a user