diff options
author | herbert <herbert@gondor.apana.org.au> | 2005-03-28 17:43:32 +1000 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2005-09-26 18:33:05 +1000 |
commit | af234c46073f28918c8604a9fde0cc3405e04f85 (patch) | |
tree | 44289bb58f5e470682aebdbb5458fcf9edc89b04 | |
parent | Removed unnecessary inclusion of main.h from eval.c. (diff) | |
download | dash-af234c46073f28918c8604a9fde0cc3405e04f85.tar.gz dash-af234c46073f28918c8604a9fde0cc3405e04f85.zip |
Handle SKIPEVAL in read_profile by exiting.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/main.c | 21 | ||||
-rw-r--r-- | src/main.h | 1 |
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 **); |