Date: Sat, 27 Aug 94 01:49:11 EDT From: peprbv AT cfa0 DOT harvard DOT edu (Bob Babcock) To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: let system() handle .bat files Reply-To: babcock AT cfa DOT harvard DOT edu Calling system() with a .bat file argument crashes because the file gets fed to spawnlp which only wants .exe or .com files. A slight rearrangement of the tests in exphdlr.c fixes this. The idea is to spawn .exe and .com files which do not have redirected output, and to pass spawn failures and anything else to system. *** ..\exphdlr.c Sat Aug 27 00:06:24 1994 --- ..\original\exphdlr.c Thu Aug 4 22:52:22 1994 *************** *** 1288,1304 **** movedata(0, 0, FP_SEG(our_interrupt_table), FP_OFF(our_interrupt_table), 256*4); uninit_controllers(); ! /* Use spawnlp for .exe and .com files without redirection or piping, system ! for everything else ! */ ! r = -1; if (strpbrk(transfer_buffer, "<>|") == NULL) ! { ! sscanf(transfer_buffer, "%s%n", buf, &i); ! bp = buf+strlen(buf)-4; ! if ((0 == stricmp(bp, ".exe")) || (0 == stricmp(bp, ".com"))) ! r = spawnlp(P_WAIT, buf, buf, transfer_buffer+i, 0); ! } ! if(r & 0x80000000L) ! r = system(transfer_buffer); init_controllers(); ctrl_break_hit = 0; --- 1288,1299 ---- movedata(0, 0, FP_SEG(our_interrupt_table), FP_OFF(our_interrupt_table), 256*4); uninit_controllers(); ! sscanf(transfer_buffer, "%s%n", buf, &i); if (strpbrk(transfer_buffer, "<>|") == NULL) ! r = spawnlp(P_WAIT, buf, buf, transfer_buffer+i, 0); ! else ! r = -1; ! bp = buf+strlen(buf)-4; ! if (stricmp(bp, ".exe") && stricmp(bp, ".com") && (r & 0x80000000L)) ! r = system(transfer_buffer); init_controllers(); ctrl_break_hit = 0; ------------------------- end of message