aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-01-30 11:04:54 -0600
committerJack Nagel2013-01-30 11:09:33 -0600
commit3414b4d689c22f11c00b029151b6bf663dd99346 (patch)
tree2ca7eb36db59f25a1b7d22a00c11fef4ad2b224c /Library
parentb6631ac23f66e554495c2f7ca48405bbf2eb9a23 (diff)
downloadbrew-3414b4d689c22f11c00b029151b6bf663dd99346.tar.bz2
Fix passing multiple switches as a single word to the build
Fixes Homebrew/homebrew#17434.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/options.rb16
-rw-r--r--Library/Homebrew/test/test_options.rb7
2 files changed, 21 insertions, 2 deletions
diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb
index e10d9483e..d8783a9d6 100644
--- a/Library/Homebrew/options.rb
+++ b/Library/Homebrew/options.rb
@@ -1,3 +1,5 @@
+require 'set'
+
class Option
include Comparable
@@ -33,6 +35,8 @@ class Option
def split_name(name)
case name
+ when /^[a-zA-Z]$/
+ [name, "-#{name}"]
when /^-[a-zA-Z]$/
[name[1..1], name]
when /^--(.+)$/
@@ -101,8 +105,16 @@ class Options
case arg
when self then arg
when Option then new << arg
- when Array then new(arg.map { |a| Option.new(a.to_s) })
- else raise TypeError, "Cannot convert #{arg.inspect} to Options"
+ when Array
+ opts = arg.map do |arg|
+ case arg
+ when /^-[^-]+$/ then arg[1..-1].split(//)
+ else arg
+ end
+ end.flatten
+ new(opts.map { |o| Option.new(o) })
+ else
+ raise TypeError, "Cannot convert #{arg.inspect} to Options"
end
end
end
diff --git a/Library/Homebrew/test/test_options.rb b/Library/Homebrew/test/test_options.rb
index 78edb408c..405ead73b 100644
--- a/Library/Homebrew/test/test_options.rb
+++ b/Library/Homebrew/test/test_options.rb
@@ -140,4 +140,11 @@ class OptionsTests < Test::Unit::TestCase
def test_coerce_raises_for_inappropriate_types
assert_raises(TypeError) { Options.coerce(1) }
end
+
+ def test_coerce_splits_multiple_switches_with_single_dash
+ array = %w{-vd}
+ verbose = Option.new("-v")
+ debug = Option.new("-d")
+ assert_equal [verbose, debug].sort, Options.coerce(array).to_a.sort
+ end
end