[Rake-devel] Rake::Win32.rake_system

Jim Weirich jim.weirich at gmail.com
Fri Sep 26 20:44:21 EDT 2008


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



More information about the Rake-devel mailing list