[Dev-luatex] os.spawn and argv[1] with sapces

T T t34www at googlemail.com
Fri Nov 27 00:00:05 CET 2009

2009/11/24 Hans Hagen <pragma at wxs.nl>:
> Reinhard Kotucha wrote:
>> On 23 November 2009 Taco Hoekwater wrote:
>>  > Let's put it this way: windows command line processing does not
>>  > agree with my neurons, so I have stayed way from it as much as
>>  > possible (and will continue to do so).
>>  >  > A good, clean patch would be welcome of course, [...]
>> Hi Taco,
>> if you change anything though, please inform the TeX Live team in
>> advance.  We probably have to adapt our scripts then.  The scripts
>> already provide a function:
> don't worry changes in these mechanism will never show up in stable versions
> unannounced as it will likely influence many; of course, as long as luatex
> functionality is not declared frozen we take the freedom to change things,
> but in this case the fact that texlua is used for scripts in tex
> distributions asks for extra care
> as far as i can see the main problem is *not* in the interface, it's just
> that the underlying windows function cannot deal with spaces in the program
> location specification and that (at some point) probably be solved in a
> compatible way

I could it give a go and try to implement something that makes sense
on Windows. The _spawnvpe function takes four arguments and two of
them, cmdname (command path/name) and argv array, are of interest

There are two cases to consider:

(1) String argument cmd_string to os.exec/os.spawn

It doesn't make sense to parse this string into argv, because
_spawnvpe will concatenate it back into single string anyway (because
that's required by CreateProcess API), but any quotation of arguments
will be lost on the way (because _spawnvpe is incredibly dumb).

Instead we can take:
argv[0] := cmd_string
argv[1] := NULL
cmdname = <first argument from cmd_string striped from quotes>

This way we can full _spawnvpe to pass the command string as is
directly to the CreateProcess API.

(2) Table argument cmd_table to os.exec/os.spawn

argv := cmd_table
if argv[0] == NULL {
  argv[0] = <argv[1] striped from quotes>

The above changes do not change the behaviour of currently working
cases, only the failing ones and those resulting in wrongly parsed
arguments being passed to the child process are affected.

If that proposal sounds OK to you, I will write a patch implementing it.



More information about the dev-luatex mailing list