dev-cmd/ruby: improve args passing

This commit is contained in:
Bo Anderson 2020-08-03 12:38:15 +01:00
parent df16e9f2de
commit b57b83feec

View File

@ -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