*** empty log message ***
[heimdal.git] / lib / editline / testit.c
blobc7216b9ffc19cc87531c489e79177202ea611ba7
1 /* $Revision$
2 **
3 ** A "micro-shell" to test editline library.
4 ** If given any arguments, commands aren't executed.
5 */
6 #if defined(HAVE_CONFIG_H)
7 #include <config.h>
8 #endif
9 #include <stdio.h>
10 #include <stdlib.h>
11 #ifdef HAVE_ERRNO_H
12 #include <errno.h>
13 #endif
15 #include "editline.h"
17 int
18 main(int ac, char **av)
20 char *p;
21 int doit;
23 doit = ac == 1;
24 while ((p = readline("testit> ")) != NULL) {
25 (void)printf("\t\t\t|%s|\n", p);
26 if (doit)
27 if (strncmp(p, "cd ", 3) == 0) {
28 if (chdir(&p[3]) < 0)
29 perror(&p[3]);
30 } else if (system(p) != 0) {
31 perror(p);
33 add_history(p);
34 free(p);
36 exit(0);
37 /* NOTREACHED */