diff options
| author | Max Howell | 2009-08-07 15:49:58 +0100 |
|---|---|---|
| committer | Max Howell | 2009-08-10 18:11:23 +0100 |
| commit | 7c791de39dd063b337b8fce35d58e989669afb2f (patch) | |
| tree | 7ff8a8ea422c82212330b4f7eb3f6d1f43991557 /Library | |
| parent | d21205067c2a77555f51f1ab74aa75d8092c3cae (diff) | |
| download | homebrew-7c791de39dd063b337b8fce35d58e989669afb2f.tar.bz2 | |
Remove duplicates from ARGV.named
Includes test
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/ARGV+yeast.rb | 2 | ||||
| -rwxr-xr-x | Library/Homebrew/unittest.rb | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Library/Homebrew/ARGV+yeast.rb b/Library/Homebrew/ARGV+yeast.rb index 92d341254..c61e2d2c2 100644 --- a/Library/Homebrew/ARGV+yeast.rb +++ b/Library/Homebrew/ARGV+yeast.rb @@ -17,7 +17,7 @@ # module HomebrewArgvExtension def named - reject {|arg| arg[0..0] == '-'} + reject{|arg| arg[0..0] == '-'}.collect{|arg| arg.downcase}.uniq end def options select {|arg| arg[0..0] == '-'} diff --git a/Library/Homebrew/unittest.rb b/Library/Homebrew/unittest.rb index 1bee7b3a6..d4339ebad 100755 --- a/Library/Homebrew/unittest.rb +++ b/Library/Homebrew/unittest.rb @@ -255,4 +255,12 @@ class BeerTasting <Test::Unit::TestCase assert_raises(RuntimeError) { f.prefix } nostdout { assert_raises(ExecutionError) { f.brew } } end + + def test_no_ARGV_dupes + ARGV.unshift'foo' + ARGV.unshift'foo' + n=0 + ARGV.named.each{|arg| n+=1 if arg == 'foo'} + assert_equal 1, n + end end |
