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

James M. Lawrence quixoticsycophant at gmail.com
Sun Nov 2 19:29:58 EST 2008

On Sun, Nov 2, 2008 at 6:27 PM, Luis Lavena <luislavena at gmail.com> wrote:
> Yes Lawrence, I remember our talk and that's why I published a follow
> up to this message:
> http://rubyforge.org/pipermail/rake-devel/2008-November/000620.html

Sorry, I didn't see that separate thread.

> So this approach will define RUBY (around line 900 in lib/rake.rb)
> depending on the platforms, and append the full extension. That is
> correct?
>  RUBY = File.join(Config::CONFIG['bindir'],
> Config::CONFIG['ruby_install_name'])
>  RUBY << Config::CONFIG['EXEEXT'] unless RUBY_PLATFORM =~ /java/
>  RUBY.sub!(/.*\s.*/m, '"\&"')
> Thoughts?

The last line looks like a bug; git blame says it was introduced on
9/21.  An executable containing quotes cannot be run with
muti-argument system().  On all platforms (not just Windows), ruby()
with multiple arguments will fail when there is whitespace in the
bindir path.

For jruby, Rake cannot use multi-argument system() for ruby().  I
think our hand is forced on this one.  All arguments will have to be
escaped and passed to single-argument system().  RUBY should not
contain the bindir path, and the constant should probably be removed

For non-jruby, your EXEEXT workaround seems doable, however I would
make sure the EXEEXT is not present before appending it.  There's a
remote possibility that some future CONFIG["ruby_install_name"] will
contain the EXEEXT.

More information about the Rake-devel mailing list