diff --git a/exec.cpp b/exec.cpp index 832c88847..c08933a10 100644 --- a/exec.cpp +++ b/exec.cpp @@ -929,7 +929,7 @@ void exec_job(parser_t &parser, job_t *j) if (p->next) { // Be careful to handle failure, e.g. too many open fds - block_output_io_buffer.reset(io_buffer_t::create(false /* = not input */, STDOUT_FILENO)); + block_output_io_buffer.reset(io_buffer_t::create(STDOUT_FILENO)); if (block_output_io_buffer.get() == NULL) { exec_error = true; @@ -958,7 +958,7 @@ void exec_job(parser_t &parser, job_t *j) { if (p->next) { - block_output_io_buffer.reset(io_buffer_t::create(0)); + block_output_io_buffer.reset(io_buffer_t::create(STDOUT_FILENO)); if (block_output_io_buffer.get() == NULL) { /* We failed (e.g. no more fds could be created). */ @@ -1606,7 +1606,7 @@ static int exec_subshell_internal(const wcstring &cmd, wcstring_list_t *lst, boo int subcommand_status = -1; //assume the worst // IO buffer creation may fail (e.g. if we have too many open files to make a pipe), so this may be null - const shared_ptr io_buffer(io_buffer_t::create(0)); + const shared_ptr io_buffer(io_buffer_t::create(STDOUT_FILENO)); if (io_buffer.get() != NULL) { parser_t &parser = parser_t::principal_parser(); diff --git a/fish_tests.cpp b/fish_tests.cpp index 7e82193cf..5b7bcea6d 100644 --- a/fish_tests.cpp +++ b/fish_tests.cpp @@ -638,7 +638,7 @@ static int signal_main(test_cancellation_info_t *info) static void test_1_cancellation(const wchar_t *src) { - shared_ptr out_buff(io_buffer_t::create(false, STDOUT_FILENO)); + shared_ptr out_buff(io_buffer_t::create(STDOUT_FILENO)); const io_chain_t io_chain(out_buff); test_cancellation_info_t ctx = {pthread_self(), 0.25 /* seconds */ }; iothread_perform(signal_main, (void (*)(test_cancellation_info_t *, int))NULL, &ctx); diff --git a/io.cpp b/io.cpp index 3395942c2..61af4a9c0 100644 --- a/io.cpp +++ b/io.cpp @@ -123,14 +123,11 @@ void io_buffer_t::read() } -io_buffer_t *io_buffer_t::create(bool is_input, int fd) +io_buffer_t *io_buffer_t::create(int fd) { bool success = true; - if (fd == -1) - { - fd = is_input ? STDIN_FILENO : STDOUT_FILENO; - } - io_buffer_t *buffer_redirect = new io_buffer_t(fd, is_input); + assert(fd >= 0); + io_buffer_t *buffer_redirect = new io_buffer_t(fd); if (exec_pipe(buffer_redirect->pipe_fd) == -1) { diff --git a/io.h b/io.h index 17e2b3421..894e4c28c 100644 --- a/io.h +++ b/io.h @@ -131,8 +131,8 @@ class io_buffer_t : public io_pipe_t /** buffer to save output in */ std::vector out_buffer; - io_buffer_t(int f, bool i): - io_pipe_t(IO_BUFFER, f, i), + io_buffer_t(int f): + io_pipe_t(IO_BUFFER, f, false /* not input */), out_buffer() { } @@ -172,16 +172,12 @@ class io_buffer_t : public io_pipe_t /** Create a IO_BUFFER type io redirection, complete with a pipe and a - vector for output. The default file descriptor used is 1 for - output buffering and 0 for input buffering. + vector for output. The default file descriptor used is STDOUT_FILENO + for buffering - \param is_input set this parameter to zero if the buffer should be - used to buffer the output of a command, or non-zero to buffer the - input to a command. - - \param fd when -1, determined from is_input. + \param fd the fd that will be mapped in the child process, typically STDOUT_FILENO */ - static io_buffer_t *create(bool is_input, int fd = -1); + static io_buffer_t *create(int fd); }; class io_chain_t : public std::vector > diff --git a/reader.cpp b/reader.cpp index 6a81f3805..069771c17 100644 --- a/reader.cpp +++ b/reader.cpp @@ -586,15 +586,6 @@ static void reader_repaint() data->repaint_needed = false; } -static void reader_repaint_without_autosuggestion() -{ - // Swap in an empty autosuggestion, repaint, then swap it out - wcstring saved_autosuggestion; - data->autosuggestion.swap(saved_autosuggestion); - reader_repaint(); - data->autosuggestion.swap(saved_autosuggestion); -} - /** Internal helper function for handling killing parts of text. */ static void reader_kill(editable_line_t *el, size_t begin_idx, size_t length, int mode, int newv) {