Add extra test functionality.

Obtained from:	NetBSD
This commit is contained in:
Mike Smith 1997-06-25 08:14:45 +00:00
parent bd5176cb38
commit 38ec47c346

View File

@ -179,28 +179,56 @@ main(argc, argv)
history(hist, continuation ? H_ADD : H_ENTER, buf); history(hist, continuation ? H_ADD : H_ENTER, buf);
continuation = 0; continuation = 0;
if (el_parse(el, ac, av) != -1) {
tok_reset(tok); if (strcmp(av[0], "history") == 0) {
continue; const struct HistEvent *he;
switch (ac) {
case 1:
for (he = history(hist, H_LAST); he;
he = history(hist, H_PREV))
(void) fprintf(stdout, "%4d %s", he->num, he->str);
break;
case 2:
if (strcmp(av[1], "clear") == 0)
history(hist, H_CLEAR);
else
goto badhist;
break;
case 3:
if (strcmp(av[1], "load") == 0)
history(hist, H_LOAD, av[2]);
else if (strcmp(av[1], "save") == 0)
history(hist, H_SAVE, av[2]);
break;
badhist:
default:
(void) fprintf(stderr, "Bad history arguments\n");
break;
}
} }
else if (el_parse(el, ac, av) == -1) {
switch (fork()) {
case 0:
execvp(av[0], av);
perror(av[0]);
_exit(1);
/*NOTREACHED*/
break;
switch (fork()) { case -1:
case 0: perror("fork");
execvp(av[0], av); break;
perror(av[0]);
_exit(1);
/*NOTREACHED*/
break;
case -1: default:
perror("fork"); if (wait(&num) == -1)
break; perror("wait");
(void) fprintf(stderr, "Exit %x\n", num);
default: break;
if (wait(&num) == -1) }
perror("wait");
(void) fprintf(stderr, "Exit %x\n", num);
break;
} }
tok_reset(tok); tok_reset(tok);
} }