delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/09/06/05:20:24

Date: Mon, 6 Sep 1999 09:29:54 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Mark E." <snowball3 AT bigfoot DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: Re: Win 9X style long command lines
In-Reply-To: <199909051618.QAA77158@out1.ibm.net>
Message-ID: <Pine.SUN.3.91.990906092935.4874D-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 5 Sep 1999, Mark E. wrote:

> I can handle detecting PE executables, but I don't enough about 4DOS
> to handle that case.

I was just talking about recognizing these programs as those who can
handle CMDLINE, nothing else.  I assume they handle CMDLINE the same
way Windows programs do.  Someone who uses 4DOS will have to see if
that assumption is correct, and if not, what has to be changed.

> > Please also note that it might be a good idea to support this feature
> > in `system' where it checks for the command line being too long (see
> > the _shell_command function)--there we *know* it's the shell that gets
> > invoked.
> >
> 
> Here's one of my sample programs I've been using:
> 
> #include <stdlib.h>
> 
> int main()
> {
>   system ("ENV.EXE one two three four five six seven eight nine ten eleven twelve 
> thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twentyone twentytwo 
> \"twentythree twentyfour\" twentyfive");
>   return 0;
> }
> 
> So you're saying system ("command.com /c env.exe one two three ...
> also needs to be handled?

No.  What I meant is that when $SHELL or $COMSPEC points to 4DOS,
*and* the command you invoke through `system' is passed to the shell
instead of emulating it, the current version of `system' still fails
when the command line is longer than 126 characters, and that if
CMDLINE is supported, it could avoid failing in this case.  See the
excerpt from system.c below.

I order to force `system' to actually call a DOSish shell, you need to
do one of the following:

   - invoke a built-in shell command or a .btm batch file;
   - set the `__system_call_cmdproc' bit in `__system_flags'.

(The first reason is by far the more frequent one, of course, but the
second one is the easiest to use in testing.)

Your example didn't force `system' to call the shell, so this code
didn't get a chance to run.



  else if (_is_dos_shell (shell))
  {
    char *cmd_tail = (char *)alloca (3 + strlen (prog) + 1
				     + strlen (cmdline) + 1);
    const char *s = prog;
    char *d = cmd_tail + 3;

    strcpy (cmd_tail, "/c ");
    while ((*d = *s++) != 0)
    {
      if (*d == '/')
	*d = '\\';
      d++;
    }

    if (*cmdline)
    {
      if (*prog)
	*d++ = ' ';

      strcpy (d, cmdline);
    }

    /* [4N]DOS.COM can support upto 255 chars per command line.
       They lose that feature here, because there's no simple
       way to pass long command lines to DOS function 4Bh (Exec)
       which `_dos_exec' summons.  */
    if (strlen (cmd_tail) > 126)
    {
      errno = E2BIG;
      return emiterror ("Command line too long.", 0);
    }
    else
      return _dos_exec (shell, cmd_tail, environ);
  }

- Raw text -


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