Issue with ChildProcess and space character in argument

Hi Jules,


If you use a command line containing a path with space characters (using the StringArray interface) it doesn't work.

I've checked the recent commit

and it doesn't do the right thing either.

Something like that works fine for me FWIW

bool ChildProcess::start (const StringArray& args, int streamFlags)
    String escaped;
    for (int i = 0; i < args.size(); ++i)
      escaped << args[i].quoted() << ' ';
    return start (escaped.trim(), streamFlags);

The current code works fine on OSX FWIW


Any idea ?



But that'd break in many cases.. Not all apps will be smart enough to strip quotes off every one of their arguments if they're expecting simple flags. And if the arguments already contain a quote, it'll also fail. That's why I used escape characters instead.

What exactly are you giving it that's failing?

I've fixed my comment and the title. I meant space and not escape character. My bad.

I'm using the unrar command line application to extract a rar file to a directory which contains a space character.

Can you give me a snippet that would let me quickly reproduce and test this?

File appDir = File::getSpecialLocation(juce::File::currentApplicationFile).getParentDirectory();
File pathToARarFile;
File pathToADirectoryWithASpace;

String rarExe = appDir.getChildFile("UnRAR.exe").getFullPathName();

StringArray commandLine;


ChildProcess process;


You can grab WinRar Here

Sorry - I actually just fixed this a few minutes ago anyway. (I think!)

I read up on how the official win32 functions handle parsing quotes and spaces, so it should be correct now.

Humm it do not seems to work.

Don't know much what's happening

Well.. I followed all the best-practice advice I could find about how to escape the arguments. Unlike unix though, it's not guaranteed that all apps will respond to this stuff in the correct way.

No biggie.

I currently concatenate stuff myself for Windows using quoted arguments and it works fine.

Thanks !