X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/95f51977ddc18faa2e212f30c00a39540b39f325..ca67e7b465996afb3821d6a075c4dc6a7f0f5d52:/usr/src/usr.bin/learn/selsub.c diff --git a/usr/src/usr.bin/learn/selsub.c b/usr/src/usr.bin/learn/selsub.c index 91f39bb1c1..6a7d3c40cf 100644 --- a/usr/src/usr.bin/learn/selsub.c +++ b/usr/src/usr.bin/learn/selsub.c @@ -1,9 +1,10 @@ #ifndef lint -static char sccsid[] = "@(#)selsub.c 4.3 (Berkeley) 5/15/86"; +static char sccsid[] = "@(#)selsub.c 4.5 (Berkeley) 10/22/87"; #endif not lint #include "stdio.h" #include "sys/types.h" +#include "sys/file.h" #include "sys/stat.h" #include "lrnref.h" @@ -73,13 +74,15 @@ char *argv[]; printf("press RETURN; otherwise type the name of\n"); printf("the course you want, followed by RETURN.\n"); fflush(stdout); - gets(sname=subname); + if (gets(sname=subname) == NULL) + exit(0); if (sname[0] == '\0') { list("Xinfo"); do { printf("\nWhich subject? "); fflush(stdout); - gets(sname=subname); + if (gets(sname=subname) == NULL) + exit(0); } while (sname[0] == '\0'); } } @@ -94,7 +97,8 @@ char *argv[]; printf("and I will look for the first lesson containing it.\n"); printf("To start at the beginning, just hit RETURN.\n"); fflush(stdout); - gets(ans2); + if (gets(ans2) == NULL) + exit(0); if (ans2[0]==0) strcpy(ans2,"0"); else @@ -119,11 +123,14 @@ char *argv[]; } /* after this point, we have a working directory. */ /* have to call wrapup to clean up */ - if (access(sprintf(ans1, "%s/%s/Init", direct, sname), 04)==0) - if (system(sprintf(ans1, "%s/%s/Init %s", direct, sname, level)) != 0) { + (void)sprintf(ans1, "%s/%s/Init", direct, sname); + if (access(ans1, R_OK)==0) { + (void)sprintf(ans1, "%s/%s/Init %s", direct, sname, level); + if (system(ans1) != 0) { printf("Leaving learn.\n"); wrapup(1); } + } } chknam(name)