Remove 'user_supplied' flag for io_fd_t

user_supplied was used to distinguish IO redirections which were
explicit, vs those that came about through "transmogrphication." But
transmogrification is no more. Remove the flag.
This commit is contained in:
ridiculousfish 2019-12-19 14:14:23 -08:00
parent 22b2dbd97d
commit 0531c02ce4
5 changed files with 11 additions and 20 deletions

View File

@ -164,7 +164,7 @@ void builtin_print_help(parser_t &parser, io_streams_t &streams, const wchar_t *
if (error_message) {
cmd.append(escape_string(*error_message, ESCAPE_ALL));
// If it's an error, redirect the output of __fish_print_help to stderr
ios.push_back(std::make_shared<io_fd_t>(STDOUT_FILENO, STDERR_FILENO, false));
ios.push_back(std::make_shared<io_fd_t>(STDOUT_FILENO, STDERR_FILENO));
}
parser.eval(cmd, ios, TOP);
// ignore the exit status of __fish_print_help

View File

@ -403,14 +403,12 @@ static bool exec_internal_builtin_proc(parser_t &parser, const std::shared_ptr<j
switch (in->io_mode) {
case io_mode_t::fd: {
const io_fd_t *in_fd = static_cast<const io_fd_t *>(in.get());
// Ignore user-supplied fd redirections from an fd other than the
// Ignore fd redirections from an fd other than the
// standard ones. e.g. in source <&3 don't actually read from fd 3,
// which is internal to fish. We still respect this redirection in
// that we pass it on as a block IO to the code that source runs,
// and therefore this is not an error. Non-user supplied fd
// redirections come about through transmogrification, and we need
// to respect those here.
if (!in_fd->user_supplied || (in_fd->old_fd >= 0 && in_fd->old_fd < 3)) {
// and therefore this is not an error.
if (in_fd->old_fd >= 0 && in_fd->old_fd < 3) {
local_builtin_stdin = in_fd->old_fd;
}
break;

View File

@ -2460,7 +2460,7 @@ static void test_dup2s() {
using std::make_shared;
io_chain_t chain;
chain.push_back(make_shared<io_close_t>(17));
chain.push_back(make_shared<io_fd_t>(3, 19, true));
chain.push_back(make_shared<io_fd_t>(3, 19));
auto list = dup2_list_t::resolve_chain(chain);
do_test(list.has_value());
do_test(list->get_actions().size() == 2);
@ -2479,10 +2479,10 @@ static void test_dup2s_fd_for_target_fd() {
io_chain_t chain;
// note io_fd_t params are backwards from dup2.
chain.push_back(make_shared<io_close_t>(10));
chain.push_back(make_shared<io_fd_t>(9, 10, true));
chain.push_back(make_shared<io_fd_t>(5, 8, true));
chain.push_back(make_shared<io_fd_t>(1, 4, true));
chain.push_back(make_shared<io_fd_t>(3, 5, true));
chain.push_back(make_shared<io_fd_t>(9, 10));
chain.push_back(make_shared<io_fd_t>(5, 8));
chain.push_back(make_shared<io_fd_t>(1, 4));
chain.push_back(make_shared<io_fd_t>(3, 5));
auto list = dup2_list_t::resolve_chain(chain);
do_test(list.has_value());

View File

@ -248,8 +248,7 @@ bool io_chain_t::append_from_specs(const redirection_spec_list_t &specs, const w
auto target_fd = spec.get_target_as_fd();
assert(target_fd.has_value() &&
"fd redirection should have been validated already");
this->push_back(
make_unique<io_fd_t>(spec.fd, *target_fd, true /* user supplied */));
this->push_back(make_unique<io_fd_t>(spec.fd, *target_fd));
}
break;
}

View File

@ -200,17 +200,11 @@ class io_fd_t : public io_data_t {
/// fd to redirect specified fd to. For example, in 2>&1, old_fd is 1, and io_data_t::fd is 2.
const int old_fd;
/// Whether this redirection was supplied by a script. For example, 'cmd <&3' would have
/// user_supplied set to true. But a redirection that comes about through transmogrification
/// would not.
const bool user_supplied;
void print() const override;
~io_fd_t() override;
io_fd_t(int f, int old, bool us)
: io_data_t(io_mode_t::fd, f), old_fd(old), user_supplied(us) {}
io_fd_t(int f, int old) : io_data_t(io_mode_t::fd, f), old_fd(old) {}
};
/// Represents a redirection to or from an opened file.