Fix superenv ENV[] hack
We override ENV[] to always return strings under superenv, because legacy formulae assume that CFLAGS, etc. are non-nil. However, the current implementation has a bug. If I simply concatenate ENV['CFLAGS'] with another string, it mutates ENV['CFLAGS']: irb> ENV['CFLAGS'] => "" irb> ENV['CFLAGS'] + 'a' => "a" irb> ENV['CFLAGS'] => "a" Instead, let's simply return an empty string if the key doesn't exist. This is sufficient because the following are equivalent: 1. ENV['CFLAGS'] += "string" 2. ENV['CFLAGS'] = ENV['CFLAGS'] + "string"
This commit is contained in:
parent
9699c0764e
commit
061f8cb35f
@ -29,15 +29,7 @@ module Superenv
|
|||||||
if has_key? key
|
if has_key? key
|
||||||
fetch(key)
|
fetch(key)
|
||||||
elsif %w{CPPFLAGS CFLAGS LDFLAGS}.include? key
|
elsif %w{CPPFLAGS CFLAGS LDFLAGS}.include? key
|
||||||
class << (a = "")
|
self[key] = ""
|
||||||
attr_accessor :key
|
|
||||||
def + value
|
|
||||||
ENV[key] = value
|
|
||||||
end
|
|
||||||
alias_method '<<', '+'
|
|
||||||
end
|
|
||||||
a.key = key
|
|
||||||
a
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user