cvsuser     04/08/05 10:31:07

  Modified:    config/gen/platform platform_interface.h
               config/gen/platform/ansi exec.c
               config/gen/platform/generic exec.c
               config/gen/platform/win32 exec.c
               ops      sys.ops
  Log:
  Added in exec opcode
  
  Revision  Changes    Path
  1.21      +1 -0      parrot/config/gen/platform/platform_interface.h
  
  Index: platform_interface.h
  ===================================================================
  RCS file: /cvs/public/parrot/config/gen/platform/platform_interface.h,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -w -r1.20 -r1.21
  --- platform_interface.h      5 May 2004 07:27:51 -0000       1.20
  +++ platform_interface.h      5 Aug 2004 17:30:50 -0000       1.21
  @@ -121,6 +121,7 @@
   struct parrot_string_t;
   struct Parrot_Interp;
   INTVAL Parrot_Run_OS_Command(struct Parrot_Interp*, struct parrot_string_t *);
  +void Parrot_Exec_OS_Command(struct Parrot_Interp*, struct parrot_string_t *);
   
   /*
    * Local variables:
  
  
  
  1.2       +5 -0      parrot/config/gen/platform/ansi/exec.c
  
  Index: exec.c
  ===================================================================
  RCS file: /cvs/public/parrot/config/gen/platform/ansi/exec.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- exec.c    19 Feb 2004 17:06:08 -0000      1.1
  +++ exec.c    5 Aug 2004 17:30:54 -0000       1.2
  @@ -6,3 +6,8 @@
       Parrot_warn(NULL, PARROT_WARNINGS_PLATFORM_FLAG, "Parrot_Run_OS_Command not 
implemented");
       return 0;
   }
  +
  +void Parrot_Exec_OS_Comman(Parrot_Interp interpreter, STRING *command) {
  +  internal_exception(NOSPAWN, "Exec not implemented");
  +
  +}
  
  
  
  1.3       +13 -0     parrot/config/gen/platform/generic/exec.c
  
  Index: exec.c
  ===================================================================
  RCS file: /cvs/public/parrot/config/gen/platform/generic/exec.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -w -r1.2 -r1.3
  --- exec.c    21 Feb 2004 11:51:03 -0000      1.2
  +++ exec.c    5 Aug 2004 17:30:58 -0000       1.3
  @@ -39,3 +39,16 @@
       }
       return 1;        /* make gcc happy */
   }
  +
  +void
  +Parrot_Exec_OS_Command(Parrot_Interp interpreter, STRING *command) {
  +  /* Be horribly profligate with memory, since we're
  +     about to be something else */
  +  int status;
  +  status = execlp("sh", "sh", "-c",
  +               string_to_cstring(interpreter, command), NULL);
  +  /* if we get here, something's horribly wrong... */
  +  if (status) {
  +    internal_exception(NOSPAWN, "Exec failed, code %i", status);
  +  }
  +}
  
  
  
  1.7       +4 -0      parrot/config/gen/platform/win32/exec.c
  
  Index: exec.c
  ===================================================================
  RCS file: /cvs/public/parrot/config/gen/platform/win32/exec.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- exec.c    2 May 2004 13:26:14 -0000       1.6
  +++ exec.c    5 Aug 2004 17:31:04 -0000       1.7
  @@ -43,3 +43,7 @@
       return status;
   }
   
  +void 
  +Parrot_Exec_OS_Command(Parrot_Interp interpreter, STRING *command) {
  +  internal_exception(NOSPAWN, "Exec not implemented");
  +}
  
  
  
  1.18      +14 -0     parrot/ops/sys.ops
  
  Index: sys.ops
  ===================================================================
  RCS file: /cvs/public/parrot/ops/sys.ops,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -w -r1.17 -r1.18
  --- sys.ops   9 Apr 2004 20:32:36 -0000       1.17
  +++ sys.ops   5 Aug 2004 17:31:07 -0000       1.18
  @@ -30,6 +30,20 @@
     goto NEXT();
   }
   
  +=item B<exec>(in STR)
  +
  +Execute the passed-in command. Completely tosses the current process
  +image and replaces it with the command. Doesn't exit (the program
  +ends, after all), though it does throw an exception if something goes
  +wrong.
  +
  +=cut
  +
  +inline op exec(in STR) {
  +  Parrot_Exec_OS_Command(interpreter, $1);
  +  goto NEXT();
  +}
  +
   ###############################################################################
   
   =item B<err>(out INT)
  
  
  

Reply via email to