delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/08/09:05:08

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 <molnarl AT cdata DOT tvnet DOT hu>
MIME-Version: 1.0
To: DJGPP workers <djgpp-workers AT delorie DOT com>
Subject: a patch for system()

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019