summary refs log tree commit diff
path: root/src/main.c
diff options
context:
space:
mode:
authorherbert <herbert@gondor.apana.org.au>2005-03-28 14:13:59 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2005-09-26 18:33:05 +1000
commit4daf75cefd7ca514d0188bae3adc8f61a63940e5 (patch)
tree862bcb1ccf0f2808e593a8cda334e5d675db77f4 /src/main.c
parentRemoved some unnecessary inclusions of input.h. (diff)
downloaddash-4daf75cefd7ca514d0188bae3adc8f61a63940e5.tar.gz
dash-4daf75cefd7ca514d0188bae3adc8f61a63940e5.zip
Generalise setinputfile for use in read_profile/readcmdfile.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 3 insertions, 16 deletions
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();