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 17:43:32 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2005-09-26 18:33:05 +1000
commitaf234c46073f28918c8604a9fde0cc3405e04f85 (patch)
tree44289bb58f5e470682aebdbb5458fcf9edc89b04 /src/main.c
parentRemoved unnecessary inclusion of main.h from eval.c. (diff)
downloaddash-af234c46073f28918c8604a9fde0cc3405e04f85.tar.gz
dash-af234c46073f28918c8604a9fde0cc3405e04f85.zip
Handle SKIPEVAL in read_profile by exiting.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 886c359..489599d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -96,6 +96,7 @@ extern int etext();
 
 STATIC void read_profile(const char *);
 STATIC char *find_dot_file(char *);
+static int cmdloop(int);
 int main(int, char **);
 
 /*
@@ -213,7 +214,7 @@ state4:	/* XXX ??? - why isn't this before the "if" statement */
  * loop; it turns on prompting if the shell is interactive.
  */
 
-void
+static int
 cmdloop(int top)
 {
 	union node *n;
@@ -227,6 +228,8 @@ cmdloop(int top)
 		hetio_init();
 #endif
 	for (;;) {
+		int skip;
+
 		setstackmark(&smark);
 		if (pendingsigs)
 			dotrap();
@@ -254,11 +257,15 @@ cmdloop(int top)
 			evaltree(n, 0);
 		}
 		popstackmark(&smark);
-		if (evalskip) {
+
+		skip = evalskip;
+		if (skip) {
 			evalskip = 0;
-			break;
+			return skip & SKIPEVAL;
 		}
 	}
+
+	return 0;
 }
 
 
@@ -270,10 +277,16 @@ cmdloop(int top)
 STATIC void
 read_profile(const char *name)
 {
+	int skip;
+
 	if (setinputfile(name, INPUT_PUSH_FILE | INPUT_NOFILE_OK) < 0)
 		return;
-	cmdloop(0);
+
+	skip = cmdloop(0);
 	popfile();
+
+	if (skip)
+		exitshell();
 }