Switch io_file_t to store an fd, not a path

Prior to this fix, a file redirection was turned into an io_file_t. This is
annoying because every place where we want to apply the redirection, we
might fail due to open() failing. Switch to opening the file at the point
we resolve the redirection spec. This will simplify a lot of code.
This commit is contained in:
ridiculousfish
2019-12-12 17:27:48 -08:00
parent af473d4d0c
commit 33aff87c10
5 changed files with 55 additions and 82 deletions

View File

@@ -2479,15 +2479,6 @@ static void test_dup2s() {
auto act2 = list->get_actions().at(1);
do_test(act2.src == 19);
do_test(act2.target == 3);
// Invalid files should fail to open.
// Suppress the debug() message.
int saved_debug_level = debug_level;
debug_level = -1;
chain.push_back(make_shared<io_file_t>(2, L"/definitely/not/a/valid/path/for/this/test", 0666));
list = dup2_list_t::resolve_chain(chain);
do_test(!list.has_value());
debug_level = saved_debug_level;
}
static void test_dup2s_fd_for_target_fd() {