aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Vandenberg2014-05-26 10:36:27 -0700
committerAdam Vandenberg2014-05-27 21:03:05 -0700
commitdc04731ce11109836b337814ed336b80b64dd6e4 (patch)
tree5bd44e50f361d493f8b583b2b1851229f0653ccd
parent355e06d433babe116156c126ae10ef44554e2b2b (diff)
downloadhomebrew-dc04731ce11109836b337814ed336b80b64dd6e4.tar.bz2
--help and --version only apply as first argument
This fixes external commands that provide their own help and version subcommands. Closes #26755.
-rw-r--r--Library/Homebrew/extend/ARGV.rb8
-rwxr-xr-xLibrary/brew.rb5
2 files changed, 3 insertions, 10 deletions
diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb
index 9f76338d0..25c2f882a 100644
--- a/Library/Homebrew/extend/ARGV.rb
+++ b/Library/Homebrew/extend/ARGV.rb
@@ -149,14 +149,6 @@ module HomebrewArgvExtension
include? '--force-bottle'
end
- def help?
- empty? || grep(/(-h$|--help$|--usage$|-\?$|help$)/).any?
- end
-
- def version?
- include? '--version'
- end
-
# eg. `foo -ns -i --bar` has three switches, n, s and i
def switch? switch_character
return false if switch_character.length > 1
diff --git a/Library/brew.rb b/Library/brew.rb
index 6d7eb3d6f..60c3109f0 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -15,11 +15,12 @@ HOMEBREW_LIBRARY_PATH = Pathname.new(__FILE__).realpath.dirname.parent.join("Lib
$:.unshift(HOMEBREW_LIBRARY_PATH.to_s)
require 'global'
-if ARGV.help?
+if ARGV.empty? || ARGV[0] =~ /(-h$|--help$|--usage$|-\?$|help$)/
+ # TODO - `brew help cmd` should display subcommand help
require 'cmd/help'
puts ARGV.usage
exit ARGV.any? ? 0 : 1
-elsif ARGV.version?
+elsif ARGV.first == '--version'
puts HOMEBREW_VERSION
exit 0
elsif ARGV.first == '-v'