From b57b83feeccbfd1435e018a5a79328a2313078e8 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 3 Aug 2020 12:38:15 +0100 Subject: [PATCH] dev-cmd/ruby: improve args passing --- Library/Homebrew/dev-cmd/ruby.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/ruby.rb b/Library/Homebrew/dev-cmd/ruby.rb index 1c2f3239ea..8b8d8eecd3 100644 --- a/Library/Homebrew/dev-cmd/ruby.rb +++ b/Library/Homebrew/dev-cmd/ruby.rb @@ -13,21 +13,26 @@ module Homebrew Run a Ruby instance with Homebrew's libraries loaded, e.g. `brew ruby -e "puts :gcc.f.deps"` or `brew ruby script.rb`. EOS - switch "-r", - description: "Load a library using `require`." - switch "-e", - description: "Execute the given text string as a script." + flag "-r=", + description: "Load a library using `require`." + flag "-e=", + description: "Execute the given text string as a script." end end def ruby - ruby_args.parse + args = ruby_args.parse + + ruby_sys_args = [] + ruby_sys_args << "-r#{args.r}" if args.r + ruby_sys_args << "-e #{args.e}" if args.e + ruby_sys_args += args.named begin safe_system RUBY_PATH, "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), "-rglobal", "-rdev-cmd/irb", - *ARGV + *ruby_sys_args rescue ErrorDuringExecution => e exit e.status.exitstatus end