[Rake-devel] Question about system call and multiple arguments.

James M. Lawrence quixoticsycophant at gmail.com
Sun Nov 2 22:37:52 EST 2008

On Sun, Nov 2, 2008 at 9:45 PM, James M. Lawrence
<quixoticsycophant at gmail.com> wrote:
>  system("cmd.exe", "/c", "test.bat", *args)  # works
>  system("cmd.exe", "/c", "c:\\path\\to\\test.bat", *args)  # works
>  system("cmd.exe", "/c", "c:\\path\\to\\foo foo\\test.bat", *args)  # fails
>  system("cmd.exe", "/c", "\"c:\\path\\to\\foo foo\\test.bat\"", *args)  # fails
> For jruby.bat and multi-argument sh() we could use the first form
> above, though bindir is still a problem.  I don't know of another
> solution.

...other than single-argument system() with a quoted full path, as in
the current RUBY constant.

So it's a toss-up between --

(1) Single-argument system() for all cases of sh(), including
multi-argument sh().  Why it's bad: the user can accidentally depend
on the shell, causing breakage on non-Windows machines.  Example:
sh("cat", "foo", ">", "out").

(2) Multi-argument system() via cmd.exe /c for multi-argument sh().
Why it's bad: assumes jruby is in PATH and is the same jruby currently

More information about the Rake-devel mailing list