home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d169 / dillonstuff.lha / src / shell / run.c < prev    next >
C/C++ Source or Header  |  1988-11-22  |  1KB  |  68 lines

  1.  
  2. /*
  3.  * RUN.C
  4.  *
  5.  *  (C)CopyRight 1987 Matthew Dillon, All rights reserved.
  6.  *
  7.  *  RUN handles running of external commands.
  8.  *
  9.  */
  10.  
  11. #include "shell.h"
  12. #include "libraries/dos.h"
  13.  
  14. extern long *SysRegs;
  15. extern struct FileLock *Clock;
  16.  
  17. do_run(str)
  18. char *str;
  19. {
  20.     int i;
  21.  
  22. #ifdef DEBUG
  23.     if (SDebug) {
  24.     printf ("RUN: %s '>%s' '<%s' '>>%ld'\n", av[0], (Cin_name)?Cin_name:"&", (Cout_name)?Cout_name:"&", Cout_append);
  25.     printf ("av[0]=%08lx [1]=%08lx [2]=%08lx\n", av[0],av[1], av[2]);
  26.     }
  27. #endif
  28.     if (fexecv(av[0], av, Cin_name, Cout_name, Cout_append) >= 0) {
  29.     i = wait();
  30.     } else {
  31.     register long lock;
  32.     register char *copy;
  33.     char buf[128];
  34.  
  35.     mountrequest(0);
  36.     lock = FindIt(av[0], ".sh", buf);
  37.     mountrequest(1);
  38. #ifdef DEBUG
  39.     if (SDebug)
  40.         puts("do_run: 1");
  41. #endif
  42.     if (lock == NULL) {
  43.         perror(av[0]);      /*  fixed 26 Mar 88 */
  44.         return (-1);
  45.     }
  46.     av[0] = (char *)-1;
  47.     av[1] = (char *)lock;
  48.     copy = malloc(strlen(str)+3);
  49.     strcpy(copy+2,str);
  50.     copy[0] = 'x';
  51.     copy[1] = ' ';
  52. #ifdef DEBUG
  53.     if (SDebug)
  54.         printf ("Do_source: %s\n", copy);
  55. #endif
  56.     i = do_source(copy);
  57.     free(copy);
  58.     }
  59.     if (Clock != (struct FileLock *)((struct Process *)FindTask(NULL))->pr_CurrentDir) {
  60.     Clock = (struct FileLock *)((struct Process *)FindTask(NULL))->pr_CurrentDir;
  61.     puts("Warning: Current Directory has changed");
  62.     }
  63.     return (i);
  64. }
  65.  
  66.  
  67.  
  68.