From 7f0a43c1e13bb0dbfb79aebd6b7b1f5f79d615ed Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 7 Feb 2009 02:57:15 +0000 Subject: [PATCH] * runruby.rb: added --precommand and --show options. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ runruby.rb | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab83cb0734..9c7b7e8515 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Feb 7 11:57:13 2009 Nobuyoshi Nakada + + * runruby.rb: added --precommand and --show options. + Sat Feb 7 11:44:06 2009 Nobuyoshi Nakada * lib/mkmf.rb (have_header): needs dependent headers if trying to 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)