aboutsummaryrefslogtreecommitdiff
path: root/lib/libedit
diff options
context:
space:
mode:
authorMike Smith <msmith@FreeBSD.org>1997-06-25 08:14:45 +0000
committerMike Smith <msmith@FreeBSD.org>1997-06-25 08:14:45 +0000
commit38ec47c3460f6e684c50c437dc2f60c18984295b (patch)
treecd0945a57dd50f5916b6c94c91cb19b70e1708f1 /lib/libedit
parentbd5176cb385550bc8bb4232c161461a65e01cd2a (diff)
downloadsrc-38ec47c3460f6e684c50c437dc2f60c18984295b.tar.gz
src-38ec47c3460f6e684c50c437dc2f60c18984295b.zip
Add extra test functionality.
Obtained from: NetBSD
Notes
Notes: svn path=/head/; revision=26927
Diffstat (limited to 'lib/libedit')
-rw-r--r--lib/libedit/TEST/test.c70
1 files changed, 49 insertions, 21 deletions
diff --git a/lib/libedit/TEST/test.c b/lib/libedit/TEST/test.c
index 2379b6f84781..097055a742c0 100644
--- a/lib/libedit/TEST/test.c
+++ b/lib/libedit/TEST/test.c
@@ -179,28 +179,56 @@ main(argc, argv)
history(hist, continuation ? H_ADD : H_ENTER, buf);
continuation = 0;
- if (el_parse(el, ac, av) != -1) {
- tok_reset(tok);
- continue;
- }
- switch (fork()) {
- case 0:
- execvp(av[0], av);
- perror(av[0]);
- _exit(1);
- /*NOTREACHED*/
- break;
-
- case -1:
- perror("fork");
- break;
-
- default:
- if (wait(&num) == -1)
- perror("wait");
- (void) fprintf(stderr, "Exit %x\n", num);
- break;
+ if (strcmp(av[0], "history") == 0) {
+ 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;
+
+ case -1:
+ perror("fork");
+ break;
+
+ default:
+ if (wait(&num) == -1)
+ perror("wait");
+ (void) fprintf(stderr, "Exit %x\n", num);
+ break;
+ }
}
tok_reset(tok);
}