On Tue, Dec 11, 2007 at 09:32:59PM +0100, Andre Poenitz wrote: > On Tue, Dec 11, 2007 at 12:19:02PM +0100, Enrico Forestieri wrote: > > > > > > process.setReadChannel(QProcess::StandardOutput); > > > - process.start(cmd.c_str(), QStringList(), QIODevice::ReadOnly); > > > + process.start(toqstr(cmd), QStringList(), QIODevice::ReadOnly); > > > > The problem is right here. This is doubly broken. First of all > > > > process.start(toqstr(cmd), QIODevice::ReadOnly); > > > > should be used. Secondly, cmd is a command whose arguments are > > quoted for being processed by a shell, but this is not so. Hence > > when calling > > > > latex 'newfile1.tex' > > > > latex is passed the filename 'newfile1.tex' *literally*, and of course > > only newfile1.tex exists. On Windows it works because double quotes > > are used and the API functions expect the quotes. > > > > Then, I think that it is better to use the QStringList version of > > start(), but the first argument should only contain the program name, > > while the arguments should be passed through the QStringList. > > This is the same as the execv family of system calls. > > This also means that some overhaul is needed, but I think it is > > unavoidable if one wants a robust implementation (using the system() > > like version of start() may become a nightmare as regards quoting). > > This is an accurate description of the problem. > > The overhaul would be a bit tedious though: There are cases where we > seem to use shell redirection in the command (see e.g. the default > > \converter lyx lyx15x "python -tt $$s/lyx2lyx/lyx2lyx -t 276 $$i > $$o" "" > > converter entry), and there are cases when arguments are already quoted, > e.g. > > configure_command_ = os::python() + ' ' + > quoteName(configure_script.toFilesystemEncoding()) + > with_version_suffix();
You are right. A parser would be needed, and it is going to become cumbersome and error prone. And then there is another difficulty on Windows, as I suspect that CreateProcess() is used there. This means that only real executables could be spawned and not batch files, unless one uses "cmd /c file.bat <args>" as a converter. -- Enrico