delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/04/18/08:19:10

Date: Thu, 18 Apr 1996 08:10:46 -0400
From: dj (DJ Delorie)
Message-Id: <199604181210.IAA11423@delorie.com>
To: eliz AT is DOT elta DOT co DOT il
CC: djgpp-workers AT delorie DOT com
In-reply-to: <Pine.SUN.3.91.960418121529.10058I-100000@is> (message from Eli Zaretskii on Thu, 18 Apr 1996 12:35:14 +0200 (IST))
Subject: Re: Spawning DOS programs

> There appears to be a contradiction between `spawnXX' and the startup code
> on c1args.c about how the command-line arguments are handled.  When you
> call `spawnXX', it assumes that every member of the argv[] array is a
> single argument.  That means that if it includes embedded whitespace or
> any special characters, they should be treated as if they were quoted. 
> This is fine with me (btw, does `execXX' on Unix behaves the same? what
> does POSIX say on this?), but when functions from dosexec.c process the

POSIX says (for exec, at least) that the argv[] you pass to exec is
EXACTLY the argv[] you get in main().  Always.

When a POSIX (or ansi) program calls system(), it's really invoking
/bin/sh, which expands the command line and generates argv[] for you.

> call, the above holds only if the program is invoked with the !proxy
> method.  If it is a DOS program or a batch file which are invoked with
> `direct_exec' or `dosexec_command_exec', the individual arguments from
> argv[] are pasted together with a blank between them.  On the other hand,
> the startup code on c1args.c only handles quoting when it gets the commad
> from DOS or from the response file, not via !proxy. 

DJGPP programs that call other djgpp programs with spawn() or exec()
will pass the correct argv[] every time, since !proxy is always used.

When we call non-djgpp programs this way, there is no way to tell
which quoting method to use, so we punt.

> What this does is that you cannot invoke programs with arguments that 
> include special characters (like whitespace and quotes) without knowing 
> in advance if it will be invoked by !proxy or otherwise.  Specifically, 
> it breaks programs that invoke inferior programs both with `spawnXX' and 
> `system'.

Spawn, perhaps, but not system.

> I think that functions on `dosexec.c' that invoke programs via DOS Exec
> call should test for special characters and if found, quote the argument
> that includes them.  (A simple solution would be to quote all the
> arguments, but that will unnecessarily enlarge the command line and might
> exceed the infamous 126-character limit.)

Which quoting will you use?  How will you know if the program will
accept the quoting you choose?

- Raw text -


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