ARGV: freeze when using CLI::Parser.
Otherwise `Homebrew.args` values may not match those of modified `ARGV`.
This commit is contained in:
parent
117c24f4b6
commit
cee75b6af2
@ -135,6 +135,7 @@ module Homebrew
|
|||||||
check_constraint_violations
|
check_constraint_violations
|
||||||
Homebrew.args[:remaining] = remaining_args
|
Homebrew.args[:remaining] = remaining_args
|
||||||
Homebrew.args.freeze
|
Homebrew.args.freeze
|
||||||
|
cmdline_args.freeze
|
||||||
@parser
|
@parser
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def irb
|
def irb
|
||||||
irb_args.parse
|
# work around IRB modifying ARGV.
|
||||||
|
irb_args.parse(ARGV.dup)
|
||||||
|
|
||||||
if args.examples?
|
if args.examples?
|
||||||
puts "'v8'.f # => instance of the v8 formula"
|
puts "'v8'.f # => instance of the v8 formula"
|
||||||
|
@ -30,7 +30,8 @@ module HomebrewArgvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def named
|
def named
|
||||||
@named ||= self - options_only
|
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||||
|
self - options_only
|
||||||
end
|
end
|
||||||
|
|
||||||
def options_only
|
def options_only
|
||||||
@ -43,7 +44,8 @@ module HomebrewArgvExtension
|
|||||||
|
|
||||||
def formulae
|
def formulae
|
||||||
require "formula"
|
require "formula"
|
||||||
@formulae ||= (downcased_unique_named - casks).map do |name|
|
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||||
|
(downcased_unique_named - casks).map do |name|
|
||||||
if name.include?("/") || File.exist?(name)
|
if name.include?("/") || File.exist?(name)
|
||||||
Formulary.factory(name, spec)
|
Formulary.factory(name, spec)
|
||||||
else
|
else
|
||||||
@ -54,19 +56,22 @@ module HomebrewArgvExtension
|
|||||||
|
|
||||||
def resolved_formulae
|
def resolved_formulae
|
||||||
require "formula"
|
require "formula"
|
||||||
@resolved_formulae ||= (downcased_unique_named - casks).map do |name|
|
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||||
|
(downcased_unique_named - casks).map do |name|
|
||||||
Formulary.resolve(name, spec: spec(nil))
|
Formulary.resolve(name, spec: spec(nil))
|
||||||
end.uniq(&:name)
|
end.uniq(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def casks
|
def casks
|
||||||
@casks ||= downcased_unique_named.grep HOMEBREW_CASK_TAP_CASK_REGEX
|
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||||
|
downcased_unique_named.grep HOMEBREW_CASK_TAP_CASK_REGEX
|
||||||
end
|
end
|
||||||
|
|
||||||
def kegs
|
def kegs
|
||||||
require "keg"
|
require "keg"
|
||||||
require "formula"
|
require "formula"
|
||||||
@kegs ||= downcased_unique_named.map do |name|
|
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||||
|
downcased_unique_named.map do |name|
|
||||||
raise UsageError if name.empty?
|
raise UsageError if name.empty?
|
||||||
|
|
||||||
rack = Formulary.to_rack(name.downcase)
|
rack = Formulary.to_rack(name.downcase)
|
||||||
@ -109,7 +114,7 @@ module HomebrewArgvExtension
|
|||||||
end
|
end
|
||||||
|
|
||||||
def include?(arg)
|
def include?(arg)
|
||||||
!(@n = index(arg)).nil?
|
!index(arg).nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def next
|
def next
|
||||||
@ -281,7 +286,8 @@ module HomebrewArgvExtension
|
|||||||
|
|
||||||
def downcased_unique_named
|
def downcased_unique_named
|
||||||
# Only lowercase names, not paths, bottle filenames or URLs
|
# Only lowercase names, not paths, bottle filenames or URLs
|
||||||
@downcased_unique_named ||= named.map do |arg|
|
# TODO: use @instance variable to ||= cache when moving to CLI::Parser
|
||||||
|
named.map do |arg|
|
||||||
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
|
if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg)
|
||||||
arg
|
arg
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user