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

Assaf Arkin assaf at labnotes.org
Sun Nov 2 19:41:00 EST 2008


On Sun, Nov 2, 2008 at 5:29 PM, James M. Lawrence <
quixoticsycophant at gmail.com> wrote:

> 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
> anyway.
>
> 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.


What about using PATH to search for the executable?

  if windows?
    path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path|
path.gsub('\\', '/') }.map { |path| "#{path}/#{name}.{exe,bat,com}" }
  else
    path = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path|
"#{path}/#{name}" }
  end
  FileList[path].existing.first

Assaf


>
> _______________________________________________
> Rake-devel mailing list
> Rake-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rake-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rake-devel/attachments/20081102/79cfb3b4/attachment-0001.html>


More information about the Rake-devel mailing list