aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorXu Cheng2016-02-26 16:10:48 +0800
committerXu Cheng2016-02-26 16:50:55 +0800
commit73b79de7bcd97e10c8d3719988bf08f94373872f (patch)
tree3f6de3a0d3e57c4a40beb2b066737bec049d8dff /Library/Homebrew/extend
parentba147818cb4144e579a35cac949ca97b1253d50e (diff)
downloadbrew-73b79de7bcd97e10c8d3719988bf08f94373872f.tar.bz2
ARGV: switch? should only has one dash
If user inputs argument such as `-with-flag`, we can assume it's a bad flag. Closes Homebrew/homebrew#49256 Closes Homebrew/homebrew#49550. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/ARGV.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index b8cfdf9fa..e7ac36628 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -195,7 +195,7 @@ module HomebrewArgvExtension
# eg. `foo -ns -i --bar` has three switches, n, s and i
def switch?(char)
return false if char.length > 1
- options_only.any? { |arg| arg[1, 1] != "-" && arg.include?(char) }
+ options_only.any? { |arg| arg.scan("-").size == 1 && arg.include?(char) }
end
def usage