def parse_env output
env = []
holder=nil
terminator=nil
output.each do |line|
line.chomp!
if holder.nil?
if line =~ /^[^=]+=([\('\$]?)/
holder = line
if $1 && !$1.empty?
terminator = $1.sub(/\$/,"'").sub(/\(/,")")
end
elsif line =~ /^[^=]*=/
holder = line
terminator=nil
else
$stderr.puts "Unknown environment token: #{line}." if ENV["TF_DEBUG"]
end
else
holder += line
end
if terminator && line.chars.to_a.last == terminator
terminator=nil
end
if holder && terminator.nil?
env << parse_var( holder.strip )
holder=nil
end
end
Hash[ env ]
end