home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / GNU_ATP_1_40.lzh / EDITLINE / testit.c < prev    next >
C/C++ Source or Header  |  1993-05-01  |  651b  |  38 lines

  1. /*  $Revision: 1.2 $
  2. **
  3. **  A "micro-shell" to test editline library.
  4. **  If given any arguments, commands aren't executed.
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. extern char    *readline();
  10. extern void    add_history();
  11. char *luxptr = NULL ;
  12.  
  13. /* ARGSUSED1 */
  14. int
  15. main(ac, av)
  16.     int        ac;
  17.     char    *av[];
  18. {
  19.     char    *p;
  20.     int        doit;
  21.  
  22.     doit = ac == 1;
  23.     while ((p = readline("testit> ")) != NULL) {
  24.     (void)printf("\t\t\t|%s|\n", p);
  25.     if (doit)
  26.         if (strncmp(p, "cd ", 3) == 0) {
  27.         if (chdir(&p[3]) < 0)
  28.             perror(&p[3]);
  29.         }
  30.         else if (system(p) != 0)
  31.         perror(p);
  32.     add_history(p);
  33.     free(p);
  34.     }
  35.     exit(0);
  36.     /* NOTREACHED */
  37. }
  38.