Mail Archives: djgpp-workers/1999/09/05/09:49:02
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 -