Merge pull request #8196 from Bo98/ruby-args
dev-cmd/ruby: improve args passing
This commit is contained in:
commit
36c10edf22
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user