From 0b5130937f9cd13287b89f1392025ca423b78acd Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Thu, 15 Aug 2024 10:14:52 -0400 Subject: [PATCH] Update debugger to fail without portable ruby --- Library/Homebrew/commands.rb | 8 ++------ Library/Homebrew/dev-cmd/debugger.rb | 8 +++++--- .../sorbet/rbi/dsl/homebrew/dev_cmd/debugger.rbi | 12 ++++++------ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb index a96c5f15d7..bd15e09d2b 100644 --- a/Library/Homebrew/commands.rb +++ b/Library/Homebrew/commands.rb @@ -42,12 +42,8 @@ module Commands end def self.valid_ruby_cmd?(cmd) - if (valid_internal_cmd?(cmd) || valid_internal_dev_cmd?(cmd) || external_ruby_v2_cmd_path(cmd)) && - (command = Homebrew::AbstractCommand.command(cmd)) - command.ruby_cmd? - else - false - end + (valid_internal_cmd?(cmd) || valid_internal_dev_cmd?(cmd) || external_ruby_v2_cmd_path(cmd)) && + Homebrew::AbstractCommand.command(cmd)&.ruby_cmd? end def self.method_name(cmd) diff --git a/Library/Homebrew/dev-cmd/debugger.rb b/Library/Homebrew/dev-cmd/debugger.rb index 545bdd91bf..255766207e 100644 --- a/Library/Homebrew/dev-cmd/debugger.rb +++ b/Library/Homebrew/dev-cmd/debugger.rb @@ -11,8 +11,8 @@ module Homebrew To pass flags to the command, use `--` to separate them from the `brew` flags. For example: `brew debugger -- list --formula`. EOS - switch "-n", "--nonstop", - description: "Do not stop at the beginning of the script." + switch "-s", "--stop", + description: "Stop at the beginning of the script." switch "-O", "--open", description: "Start remote debugging over a Unix socket." @@ -21,12 +21,14 @@ module Homebrew sig { override.void } def run + raise UsageError, "Debugger is only supported with portable Ruby!" unless HOMEBREW_USING_PORTABLE_RUBY + unless Commands.valid_ruby_cmd?(args.named.first) raise UsageError, "`#{args.named.first}` is not a valid Ruby command!" end brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path - nonstop = "1" if args.nonstop? + nonstop = "1" unless args.stop? debugger_method = if args.open? "open" else diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/debugger.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/debugger.rbi index 9c09f8a29b..25d8b7d75f 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/debugger.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/dev_cmd/debugger.rbi @@ -14,12 +14,12 @@ class Homebrew::DevCmd::Debugger::Args < Homebrew::CLI::Args sig { returns(T::Boolean) } def O?; end - sig { returns(T::Boolean) } - def n?; end - - sig { returns(T::Boolean) } - def nonstop?; end - sig { returns(T::Boolean) } def open?; end + + sig { returns(T::Boolean) } + def s?; end + + sig { returns(T::Boolean) } + def stop?; end end