brew: check for --help and friends in more of ARGV
Let's check for e.g. --help anywhere in the ARGV array rather than just the first value to avoid brew upgrade --help causing problems. Closes Homebrew/homebrew#26675. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
a7b515e503
commit
eabe9dc6d0
@ -157,6 +157,14 @@ 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
|
||||
|
||||
@ -16,14 +16,14 @@ $:.unshift(HOMEBREW_LIBRARY_PATH + '/vendor')
|
||||
$:.unshift(HOMEBREW_LIBRARY_PATH)
|
||||
require 'global'
|
||||
|
||||
case ARGV.first when '-h', '--help', '--usage', '-?', 'help', nil
|
||||
if ARGV.help?
|
||||
require 'cmd/help'
|
||||
puts Homebrew.help_s
|
||||
exit ARGV.first ? 0 : 1
|
||||
when '--version'
|
||||
puts ARGV.usage
|
||||
exit ARGV.any? ? 0 : 1
|
||||
elsif ARGV.version?
|
||||
puts HOMEBREW_VERSION
|
||||
exit 0
|
||||
when '-v'
|
||||
elsif ARGV.first == '-v'
|
||||
puts "Homebrew #{HOMEBREW_VERSION}"
|
||||
# Shift the -v to the end of the parameter list
|
||||
ARGV << ARGV.shift
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user