Fixes for /usr/xbin binaries bootstrap dir.
[minix3.git] / lib / editline / testit.c
blobdf2f5aa51f7bbbdd4a09c0958b36ebc5a77ead72
1 /* $Revision$
2 **
3 ** A "micro-shell" to test editline library.
4 ** If given any arguments, commands aren't executed.
5 */
6 #include <stdio.h>
7 #if defined(HAVE_STDLIB)
8 #include <stdlib.h>
9 #endif /* defined(HAVE_STDLIB) */
11 extern char *readline();
12 extern void add_history();
14 #if !defined(HAVE_STDLIB)
15 extern int chdir();
16 extern int free();
17 extern int strncmp();
18 extern int system();
19 extern void exit();
20 extern char *getenv();
21 #endif /* !defined(HAVE_STDLIB) */
24 #if defined(NEED_PERROR)
25 void
26 perror(s)
27 char *s;
29 extern int errno;
31 (voidf)printf(stderr, "%s: error %d\n", s, errno);
33 #endif /* defined(NEED_PERROR) */
36 /* ARGSUSED1 */
37 int
38 main(ac, av)
39 int ac;
40 char *av[];
42 char *prompt;
43 char *p;
44 int doit;
46 doit = ac == 1;
47 if ((prompt = getenv("TESTPROMPT")) == NULL)
48 prompt = "testit> ";
50 while ((p = readline(prompt)) != NULL) {
51 (void)printf("\t\t\t|%s|\n", p);
52 if (doit)
53 if (strncmp(p, "cd ", 3) == 0) {
54 if (chdir(&p[3]) < 0)
55 perror(&p[3]);
57 else if (system(p) != 0)
58 perror(p);
59 add_history(p);
60 free(p);
62 exit(0);
63 /* NOTREACHED */
67 * $PchId: testit.c,v 1.3 1996/02/22 21:18:51 philip Exp $