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.
This commit is contained in:
ridiculousfish 2021-02-07 16:21:33 -08:00
parent 17707065b8
commit 40d8e7e983

View File

@ -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;
}