Ignore user-supplied fd redirections above 2 for builtins

Prevents e.g. specifying an fd which corresponds to the history file
as the stdin for builtin_source
This commit is contained in:
ridiculousfish
2015-01-08 10:44:05 -08:00
parent 7864d0d416
commit 34db67680d
3 changed files with 14 additions and 6 deletions

8
io.h
View File

@@ -66,11 +66,15 @@ 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;
virtual void print() const;
io_fd_t(int f, int old) :
io_fd_t(int f, int old, bool us) :
io_data_t(IO_FD, f),
old_fd(old)
old_fd(old),
user_supplied(us)
{
}
};