From 4daf75cefd7ca514d0188bae3adc8f61a63940e5 Mon Sep 17 00:00:00 2001 From: herbert Date: Mon, 28 Mar 2005 14:13:59 +1000 Subject: Generalise setinputfile for use in read_profile/readcmdfile. --- src/main.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index b6dea21..886c359 100644 --- a/src/main.c +++ b/src/main.c @@ -270,13 +270,7 @@ cmdloop(int top) STATIC void read_profile(const char *name) { - int fd; - - INTOFF; - if ((fd = open(name, O_RDONLY)) >= 0) - setinputfd(fd, 1); - INTON; - if (fd < 0) + if (setinputfile(name, INPUT_PUSH_FILE | INPUT_NOFILE_OK) < 0) return; cmdloop(0); popfile(); @@ -291,14 +285,7 @@ read_profile(const char *name) void readcmdfile(char *name) { - int fd; - - INTOFF; - if ((fd = open(name, O_RDONLY)) >= 0) - setinputfd(fd, 1); - else - sh_error("Can't open %s", name); - INTON; + setinputfile(name, INPUT_PUSH_FILE); cmdloop(0); popfile(); } @@ -347,7 +334,7 @@ dotcmd(int argc, char **argv) char *fullname; fullname = find_dot_file(argv[1]); - setinputfile(fullname, 1); + setinputfile(fullname, INPUT_PUSH_FILE); commandname = fullname; cmdloop(0); popfile(); -- cgit 1.4.1