[Rake-devel] Rake::Win32.rake_system

Turpin, Jay jay.turpin at intel.com
Mon Sep 29 12:00:22 EDT 2008


Jim,

That's much cleaner - I fixed a minor typo in the example you sent and tested on my machine. Seems to work fine. Any idea when we'll see a new gem with the fix in it?

def perform_variable_expansion(cmd)
   cmd.gsub!(/%([A-Za-z_]+)%/) { |k| ENV[$1] || k }
end

Thanks for the help!

Regards,
Jay Turpin
"May the road rise up to meet you. May the wind be always at your back. The rain falls soft upon your fields. And until we meet again, may God hold you in the palm of His hand." - Irish blessing
-----Original Message-----
From: rake-devel-bounces at rubyforge.org [mailto:rake-devel-bounces at rubyforge.org] On Behalf Of Jim Weirich
Sent: Friday, September 26, 2008 5:44 PM
To: Rake Development and Discussion
Subject: Re: [Rake-devel] Rake::Win32.rake_system


On Sep 26, 2008, at 12:18 PM, Turpin, Jay wrote:

> OK - now I understand why this was done. However, the CALL command
> is choking on any commands sent to sh that contains a newline
> character. It's not pretty, but this fix appears to resolve the
> problem (at least all of the tests pass):
>
> # Run a command line on windows.
> def rake_system(*cmd)
>  perform_variable_expansion cmd[0]
>  system(*cmd)
> end
>
> def perform_variable_expansion(cmd)
>  ENV.each do |k, v|
>    cmd.sub!(/\%#{k}\%/i, v)
>  end
> end

Perform the variable expansion by hand?  Ok by me.

I'm thinking I like this for the expansion:

def perform_variable_expansion(cmd)
   s.gsub!(/%([A-Za-z_]+)%/) { |k| ENV[$1] || k }
end


--
-- Jim Weirich
-- jim.weirich at gmail.com

_______________________________________________
Rake-devel mailing list
Rake-devel at rubyforge.org
http://rubyforge.org/mailman/listinfo/rake-devel


More information about the Rake-devel mailing list