diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 4c0b66d948..c0f82d7e9e 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -301,7 +301,7 @@ module Homebrew # If we accept formula options, but the command isn't scoped only # to casks, parse once allowing invalid options so we can get the # remaining list containing formula names. - if @formula_options && argv.exclude?("--cask") + if @formula_options && !only_casks?(argv) remaining, non_options = parse_remaining(argv, ignore_invalid_options: true) argv = [*remaining, "--", *non_options] @@ -640,6 +640,10 @@ module Homebrew end end.compact.uniq(&:name) end + + def only_casks?(argv) + argv.include?("--casks") || argv.include?("--cask") + end end class OptionConstraintError < UsageError