summaryrefslogtreecommitdiff
path: root/runruby.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-07 02:57:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-07 02:57:15 +0000
commit7f0a43c1e13bb0dbfb79aebd6b7b1f5f79d615ed (patch)
tree3b2026da92c4cc115afaaa44f76912fd3204ade9 /runruby.rb
parent7c93e565600f3645659e603161c9ac992184c7d0 (diff)
* runruby.rb: added --precommand and --show options.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'runruby.rb')
-rwxr-xr-xrunruby.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/runruby.rb b/runruby.rb
index c439784042..900469c1d4 100755
--- a/runruby.rb
+++ b/runruby.rb
@@ -1,6 +1,8 @@
#!./miniruby
pure = true
+show = false
+precommand = []
while arg = ARGV[0]
break ARGV.shift if arg == '--'
/\A--([-\w]+)(?:=(.*))?\z/ =~ arg or break
@@ -16,7 +18,13 @@ while arg = ARGV[0]
when re =~ "pure"
pure = (value != "no")
when re =~ "debugger"
- debugger = value ? (value.split unless value == "no") : %w"gdb --args"
+ require 'shellwords'
+ precommand.concat(value ? (Shellwords.shellwords(value) unless value == "no") : %w"gdb --args")
+ when re =~ "precommand"
+ require 'shellwords'
+ precommand.concat(Shellwords.shellwords(value))
+ when re =~ "show"
+ show = true
else
break
end
@@ -72,8 +80,12 @@ ENV.update env
cmd = [ruby]
cmd << "-rpurelib.rb" if pure
cmd.concat(ARGV)
-cmd.unshift(*debugger) if debugger
+cmd.unshift(*precommand) unless precommand.empty?
-#require 'shellwords'; puts Shellwords.join(env.map {|k,v| "#{k}=#{v}" } + cmd)
+if show
+ require 'shellwords'
+ env.each {|k,v| puts "#{k}=#{v}"}
+ puts Shellwords.join(cmd)
+end
exec(*cmd)