From 40d8e7e98337b239358f37260ff3f3e280336642 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 7 Feb 2021 16:21:33 -0800 Subject: [PATCH] Correct the sense of a test for builtin stdin fds fish isn't quite sure what to do if the user specifies an fd redirection for builtins. For example `source <&5` could potentially just read from an arbitrary file descriptor internal to fish, like the history file. fish has some lame code that tries to detect these, but got the sense wrong. Fix it so that fd redirections for builtins are restricted to range 0 through 2. --- src/exec.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index f3aa2f4a3..0bf7d7076 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -390,8 +390,7 @@ static launch_result_t exec_internal_builtin_proc(parser_t &parser, process_t *p // 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. - bool ignore_redirect = - in->io_mode == io_mode_t::fd && in->source_fd >= 0 && in->source_fd < 3; + bool ignore_redirect = in->io_mode == io_mode_t::fd && in->source_fd >= 3; if (!ignore_redirect) { local_builtin_stdin = in->source_fd; }