Fix normalization of old- and new-style options

When combining the set of old-style and new-style options, make sure
that the leading "--" is stripped.

Fixes displaying options in `brew options`, and the exotic case of
declaring options using the old syntax and then checking them with
`build.include?`
This commit is contained in:
Misty De Meo 2012-08-11 16:51:05 -05:00
parent 5882ae901f
commit d1c0d4c879
2 changed files with 5 additions and 3 deletions

View File

@ -32,8 +32,7 @@ module Homebrew extend self
def dump_options_for_formula f
f.build.each do |k,v|
k.prepend "--" unless k.start_with? "--"
puts k
puts "--"+k
puts "\t"+v
end
end

View File

@ -58,7 +58,10 @@ class Formula
@downloader = download_strategy.new(name, @active_spec)
# Combine DSL `option` and `def options`
options.each {|o| self.class.build.add(o[0], o[1]) }
options.each do |opt, desc|
# make sure to strip "--" from the start of options
self.class.build.add opt[/--(.+)$/, 1], desc
end
end
def url; @active_spec.url; end