home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / text / emacsdif.lha / emacs-18.58 / etc / sh.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-17  |  615 b   |  30 lines

  1. #include <exec/types.h>
  2. #include <dos/dostags.h>
  3. #include <stdio.h>
  4.  
  5. #include <proto/dos.h>
  6.  
  7. int execute(char *cmd)
  8. {
  9.     long rc;
  10.  
  11.     while (*cmd == ' ') cmd++;
  12.     if (strncmp(cmd, "exec", 4) == 0 && (cmd[4] == ' ' || cmd[4] == '\t')) cmd += 4;
  13.     if ((rc = SystemTags(cmd, SYS_UserShell, TRUE, TAG_END)) == -1)
  14.     {
  15.     fprintf(stderr, "Failed to execute command %s\n", cmd);
  16.     return 20;
  17.     }
  18.     return rc;
  19. }
  20.  
  21. void main(int argc, char **argv)
  22. {
  23.     if (argc == 3 && strcmp(argv[1], "-c") == 0) exit(execute(argv[2]));
  24.     else
  25.     {
  26.     fprintf(stderr, "Only sh -c <command> is recognized\n");
  27.     exit(20);
  28.     }
  29. }
  30.