From 11a0ea18335cf1901e5e21c964493e2a233cc058 Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Sat, 4 Mar 2023 16:42:34 -0800 Subject: [PATCH] irb: enable global options The --debug and --quiet options weren't working before with the REPL because IRB didn't recognize them. --- Library/Homebrew/dev-cmd/irb.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Library/Homebrew/dev-cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb index 3f032038be..0112023703 100644 --- a/Library/Homebrew/dev-cmd/irb.rb +++ b/Library/Homebrew/dev-cmd/irb.rb @@ -39,6 +39,8 @@ module Homebrew # work around IRB modifying ARGV. args = irb_args.parse(ARGV.dup.freeze) + clean_argv + if args.examples? puts <<~EOS 'v8'.f # => instance of the v8 formula @@ -68,4 +70,13 @@ module Homebrew IRB.start end end + + # Remove the `--debug`, `--verbose` and `--quiet` options which cause problems + # for IRB and have already been parsed by the CLI::Parser. + def clean_argv + global_options = Homebrew::CLI::Parser + .global_options + .flat_map { |options| options[0..1] } + ARGV.reject! { |arg| global_options.include?(arg) } + end end