diff options
author | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
---|---|---|
committer | assar <assar@FreeBSD.org> | 2001-06-21 02:12:07 +0000 |
commit | 0c8fa354358381b3f1b92598e7f1b46f8cf744cc (patch) | |
tree | ed28ffb73cc0ae48a9892dab3f10b09bc36436d5 /crypto/heimdal/lib/editline/testit.c | |
parent | 06c859ecf534f468a52f24a3eb14409d73a4907c (diff) | |
download | FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.zip FreeBSD-src-0c8fa354358381b3f1b92598e7f1b46f8cf744cc.tar.gz |
import of heimdal 0.3f
Diffstat (limited to 'crypto/heimdal/lib/editline/testit.c')
-rw-r--r-- | crypto/heimdal/lib/editline/testit.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/crypto/heimdal/lib/editline/testit.c b/crypto/heimdal/lib/editline/testit.c new file mode 100644 index 0000000..4635e36 --- /dev/null +++ b/crypto/heimdal/lib/editline/testit.c @@ -0,0 +1,38 @@ +/* $Revision: 1.2 $ +** +** A "micro-shell" to test editline library. +** If given any arguments, commands aren't executed. +*/ +#if defined(HAVE_CONFIG_H) +#include <config.h> +#endif +#include <stdio.h> +#include <stdlib.h> +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif + +#include "editline.h" + +int +main(int ac, char **av) +{ + char *p; + int doit; + + doit = ac == 1; + while ((p = readline("testit> ")) != NULL) { + (void)printf("\t\t\t|%s|\n", p); + if (doit) + if (strncmp(p, "cd ", 3) == 0) { + if (chdir(&p[3]) < 0) + perror(&p[3]); + } else if (system(p) != 0) { + perror(p); + } + add_history(p); + free(p); + } + exit(0); + /* NOTREACHED */ +} |