Environment.execute() expands $ variable references recursively

This commit is contained in:
Josh Holtrop 2013-06-26 21:27:57 -04:00
parent 58d7f4edd5
commit 116406c74d

View File

@ -48,7 +48,26 @@ module Rscons
end end
def execute(short_desc, command) def execute(short_desc, command)
command = command.flatten expand_varref = proc do |varref|
if varref.is_a?(Array)
varref.map do |ent|
expand_varref.call(ent)
end
else
if varref[0] == '$'
varname = varref[1, varref.size]
varval = self[varname]
if varval
expand_varref.call(varval)
else
raise "Could not find variable #{varname.inspect}"
end
else
varref
end
end
end
command = expand_varref.call(command.flatten).flatten
if @echo == :command if @echo == :command
puts command.join(' ') puts command.join(' ')
elsif @echo == :short elsif @echo == :short