delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/09/05/09:49:02

Date: Sun, 5 Sep 1999 15:31:41 +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: <199909050447.EAA74932@out5.ibm.net>
Message-ID: <Pine.SUN.3.91.990905152954.20300V-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:

> Today I decided to try and see if I could get DJGPP to understand
> and generate Win 9X style long command lines.

Thanks for working on this.

The comments below are based on source inspection only.

>     if (argp - args > CMDLEN_LIMIT)
> + #if 0
>       errno = E2BIG;
> + #else
> +   {
> +     /* The command line is too long to pass directly. Put the entire
> +        contents of the command line into the CMDLINE variable and
> +        set the command line length to 127 in direct_exec_tail.

I don't think it is a good idea to do this unconditionally.  Some
applications (notably, Bash) depend on E2BIG being returned for long
command lines (they then revert to response file as an alternative).

I think we need some way of detecting whether the invoked program
supports the $CMDLINE method.  How about extending _check_v2_prog (sp?)
so that it also recognizes a PE executable?  (4DOS and its ilk could
be recognized by their names.)

> +        This method is understood by 32-bit Windows and 4DOS.
> +        Others will just get the truncated command line.  */

4DOS (and NDOS, btw) is only relevant if the invoked program is the
shell.

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.

> +       while (*p)
> +       {
> +         if (*p == '"' && (quoted || need_quote))
> +           *argp++ = '\\';
> +         else if (*p == '\\' && p[1] == '\'' && unescape_quote)
> +           p++;
> +         *argp++ = *p++;
> +       }

The quoting would need some special testing.  The quoted arguments
support in Windows programs is an undocumented mess full of
incompatibilities.  Perhaps we should DTRT at least for Cygwin- and
Mingw-compiled programs.

As a matter of fact, building some package with Cygwin or Mingw tools
invoked with DJGPP Make built with this patch would be a good test
case.

> !     else
> !     {
> !       /* Command line is in the environment variable CMDLINE.  */
> !       char *cmdline = getenv("CMDLINE");
> !       if (cmdline)
> !       {
> !         char stop_token;
> ! 
> !         /* Skip over the name of the program.  */
> !         if ((*cmdline == '\"') || (*cmdline == '\''))
> !           stop_token = *cmdline;
> !         else
> !           stop_token = ' ';
> ! 
> !         while (*cmdline != stop_token)
> !           ++cmdline;
> ! 
> !         ++cmdline; /* Skip over the stop token.  */
> ! 
> !         arglist = parse_bytes(cmdline, strlen(cmdline),
> !                               (_crt0_startup_flags & _CRT0_FLAG_KEEP_QUOTES) == 0);
> !       }
> !       else
> !       {
> !         abort();
> !       }

Isn't it better to fall back on the usual DOS command-line tail
instead of abort()'ing?

- Raw text -


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