summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ChangeLog1
-rw-r--r--src/main.c21
-rw-r--r--src/main.h1
3 files changed, 18 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8cd48dc..66952e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
 	* Removed some unnecessary inclusions of input.h.
 	* Removed unnecessary inclusion of main.h from eval.c.
 	* Generalise setinputfile for use in read_profile/readcmdfile.
+	* Handle SKIPEVAL in read_profile by exiting.
 
 2005-03-25  Gerrit Pape <pape@smarden.org>
 
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();
 }
 
 
diff --git a/src/main.h b/src/main.h
index 6b8e71c..10cc854 100644
--- a/src/main.h
+++ b/src/main.h
@@ -54,6 +54,5 @@ extern int *dash_errno;
 #endif
 
 void readcmdfile(char *);
-void cmdloop(int);
 int dotcmd(int, char **);
 int exitcmd(int, char **);