Sender: ml AT delorie DOT com Message-ID: <3413F6B4.6D5CEBFE@cdata.tvnet.hu> Date: Mon, 08 Sep 1997 14:59:32 +0200 From: Molnar Laszlo MIME-Version: 1.0 To: DJGPP workers Subject: a patch for system() Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Hi Workers! I have a problem with system(), when I try to run a non-existing program. I always have SHELL=path/to/bash when working with djgpp programs. But perl says, that I shouldn't start a shell with system() when don't need. So I simply check for some magic character in the command line, and if I find none, I set __sys_flags to use __system_emulate_command. And here is my problem. When system() tries to run a nonexistent program, its "last resort" is to pass it to the shell. If the shell was command.com, I get 0 as the return code, and if it was bash, I get 127. Instead of -1. Here is the patch I use: *** system.c~ Sun Aug 31 15:40:56 1997 --- system.c Sun Sep 7 22:54:30 1997 *************** *** 245,249 **** endcmd = 0; } ! if (endcmd && (stricmp (endcmd, "exe") == 0 || stricmp (endcmd, "com") == 0 --- 245,249 ---- endcmd = 0; } ! if ((sys_flags & __system_emulate_command) || endcmd && (stricmp (endcmd, "exe") == 0 || stricmp (endcmd, "com") == 0