Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AquaGeek/971613 to your computer and use it in GitHub Desktop.
Save AquaGeek/971613 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #2104
From 19d911aedaabbeeb7d3505b4085f726f5830bbe8 Mon Sep 17 00:00:00 2001
From: Charles Nutter <[email protected]>
Date: Sat, 28 Feb 2009 17:47:00 -0600
Subject: [PATCH] Move away from using exec to launch console.
---
railties/lib/commands/console.rb | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/railties/lib/commands/console.rb b/railties/lib/commands/console.rb
index 63df834..c9a7018 100644
--- a/railties/lib/commands/console.rb
+++ b/railties/lib/commands/console.rb
@@ -1,6 +1,5 @@
-irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
-
require 'optparse'
+require 'irb'
options = { :sandbox => false, :irb => irb }
OptionParser.new do |opt|
@@ -11,16 +10,15 @@ OptionParser.new do |opt|
opt.parse!(ARGV)
end
-libs = " -r irb/completion"
-libs << %( -r "#{RAILS_ROOT}/config/environment")
-libs << " -r console_app"
-libs << " -r console_sandbox" if options[:sandbox]
-libs << " -r console_with_helpers"
+require "irb/completion"
+require "#{RAILS_ROOT}/config/environment"
+require "console_app"
+require "console_sandbox" if options[:sandbox]
+require "console_with_helpers"
if options[:debugger]
begin
require 'ruby-debug'
- libs << " -r ruby-debug"
puts "=> Debugger enabled"
rescue Exception
puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
@@ -42,4 +40,6 @@ if options[:sandbox]
else
puts "Loading #{ENV['RAILS_ENV']} environment (Rails #{Rails.version})"
end
-exec "#{options[:irb]} #{libs} --simple-prompt"
+
+ARGV.replace(["--simple-prompt"])
+IRB.start
--
1.6.0.2
From 97eb21c390585de13bd3d2b4cf1d261a300423c8 Mon Sep 17 00:00:00 2001
From: Jason King <[email protected]>
Date: Mon, 2 Mar 2009 12:34:41 +1100
Subject: [PATCH] Fixed command line parsing of environment
---
railties/bin/console | 9 +++++++++
railties/lib/commands/console.rb | 8 --------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/railties/bin/console b/railties/bin/console
index 498077a..0227ebe 100755
--- a/railties/bin/console
+++ b/railties/bin/console
@@ -1,3 +1,12 @@
#!/usr/bin/env ruby
+
+ENV['RAILS_ENV'] = case ARGV.first
+ when "p"; "production"
+ when "d"; "development"
+ when "t"; "test"
+ else
+ ARGV.first || ENV['RAILS_ENV'] || 'development'
+end
+
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
diff --git a/railties/lib/commands/console.rb b/railties/lib/commands/console.rb
index 45acd18..a252a19 100644
--- a/railties/lib/commands/console.rb
+++ b/railties/lib/commands/console.rb
@@ -25,14 +25,6 @@ if options[:debugger]
end
end
-ENV['RAILS_ENV'] = case ARGV.first
- when "p"; "production"
- when "d"; "development"
- when "t"; "test"
- else
- ARGV.first || ENV['RAILS_ENV'] || 'development'
-end
-
if options[:sandbox]
puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})"
puts "Any modifications you make will be rolled back on exit"
--
1.6.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment