summaryrefslogtreecommitdiff
path: root/tool/runruby.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-05 21:13:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-05 21:13:17 +0000
commitca551eed45fe416292ae08ed018c772cb430d5cb (patch)
tree63432edca11b3b7ebb962d6e6abab8b15c9ddae8 /tool/runruby.rb
parent0523a4200cb542c30fbea6414dcfaba651316318 (diff)
runruby.rb: add -C/--chdir option
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/runruby.rb')
-rwxr-xr-xtool/runruby.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/tool/runruby.rb b/tool/runruby.rb
index dc2cced1d0..662c0aef35 100755
--- a/tool/runruby.rb
+++ b/tool/runruby.rb
@@ -5,8 +5,15 @@
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]
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)
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