ruby-changes:48549
From: nobu <ko1@a...>
Date: Mon, 6 Nov 2017 06:13:23 +0900 (JST)
Subject: [ruby-changes:48549] nobu:r60664 (trunk): runruby.rb: add -C/--chdir option
nobu 2017-11-06 06:13:17 +0900 (Mon, 06 Nov 2017) New Revision: 60664 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60664 Log: runruby.rb: add -C/--chdir option Modified files: trunk/tool/runruby.rb Index: tool/runruby.rb =================================================================== --- tool/runruby.rb (revision 60663) +++ tool/runruby.rb (revision 60664) @@ -5,8 +5,15 @@ https://github.com/ruby/ruby/blob/trunk/tool/runruby.rb#L5 show = false precommand = [] +srcdir = File.realpath('..', File.dirname(__FILE__)) while arg = ARGV[0] break ARGV.shift if arg == '--' + case arg + when '-C', /\A-C(.+)/m + ARGV.shift + Dir.chdir($1 || ARGV.shift) + next + end /\A--([-\w]+)(?:=(.*))?\z/ =~ arg or break arg, value = $1, $2 re = Regexp.new('\A'+arg.gsub(/\w+\b/, '\&\\w*')+'\z', "i") @@ -35,6 +42,8 @@ while arg = ARGV[0] https://github.com/ruby/ruby/blob/trunk/tool/runruby.rb#L42 precommand.concat(Shellwords.shellwords(value)) when re =~ "show" show = true + when re =~ "chdir" + Dir.chdir(value) else break end @@ -53,10 +62,10 @@ unless defined?(File.realpath) https://github.com/ruby/ruby/blob/trunk/tool/runruby.rb#L62 end end -srcdir ||= File.realpath('..', File.dirname(__FILE__)) begin conffile = File.realpath('rbconfig.rb', archdir) rescue Errno::ENOENT => e + # retry if !archdir and ARGV[0] and File.directory?(archdir = ARGV.shift) abort "#$0: rbconfig.rb not found, use --archdir option" end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/