1 /* $Id: exit.c,v 1.11 2020-11-19 02:31:31 phil Exp $ */ 2 3 /* 4 * SPARC SPITBOL compatibility; 5 * LOAD("EXIT()") 6 * 7 * Usage; EXIT("command") 8 * Returns; fails, or passes execution to command string 9 * 10 * partial simulation of SPITBOL EXIT() 11 */ 12 13 #ifdef HAVE_CONFIG_H 14 #include "config.h" 15 #endif /* HAVE_CONFIG_H defined */ 16 17 #include <stdio.h> /* for lib.h */ 18 #include <stdlib.h> /* for free() */ 19 20 #include "h.h" 21 #include "snotypes.h" 22 #include "macros.h" 23 24 #include "load.h" /* LA_xxx macros */ 25 #include "equ.h" /* datatypes I/S */ 26 #include "lib.h" /* io_flushall(),execute() */ 27 28 pmlret_t EXIT(LA_ALIST)29EXIT( LA_ALIST ) { 30 char *str; 31 32 (void) retval; 33 (void) nargs; 34 if (LA_TYPE(0) == S) { /* EXIT("command") */ 35 str = mgetstring(LA_PTR(0)); 36 io_flushall(0); /* flush output buffers */ 37 execute(str); /* should not return */ 38 /* ~sigh~ */ 39 free(str); 40 RETFAIL; 41 } 42 43 /* save files not supported */ 44 RETFAIL; 45 } 46