aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-03-25 13:20:59 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2016-03-26 20:18:51 +0900
commit06cd7ab6cb1e0ecae5a3fedaecb7facc4bf52ad9 (patch)
treecbe716496551e592c35b5a9ad603a616f79567fb /railties
parent96ec8d92b12ecb6cc7e7744f7ad5deb7676ce7d2 (diff)
downloadrails-06cd7ab6cb1e0ecae5a3fedaecb7facc4bf52ad9.tar.gz
rails-06cd7ab6cb1e0ecae5a3fedaecb7facc4bf52ad9.tar.bz2
rails-06cd7ab6cb1e0ecae5a3fedaecb7facc4bf52ad9.zip
show correct command name in help of rails runner
If use rails together with `spring`, `spring` is rewrite `$0` in the interior command name. Therefore, for `$0` correct command name does not appear, `$0` has been modified so that it does not use.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/commands/runner.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb
index 5844e9037c..f9c183ac86 100644
--- a/railties/lib/rails/commands/runner.rb
+++ b/railties/lib/rails/commands/runner.rb
@@ -2,6 +2,7 @@ require 'optparse'
options = { environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup }
code_or_file = nil
+command = 'bin/rails runner'
if ARGV.first.nil?
ARGV.push "-h"
@@ -34,7 +35,7 @@ ARGV.clone.options do |opts|
opts.separator ""
opts.separator "You can also use runner as a shebang line for your executables:"
opts.separator " -------------------------------------------------------------"
- opts.separator " #!/usr/bin/env #{File.expand_path($0)} runner"
+ opts.separator " #!/usr/bin/env #{File.expand_path(command)}"
opts.separator ""
opts.separator " Product.all.each { |p| p.price *= 2 ; p.save! }"
opts.separator " -------------------------------------------------------------"
@@ -52,7 +53,7 @@ Rails.application.require_environment!
Rails.application.load_runner
if code_or_file.nil?
- $stderr.puts "Run '#{$0} -h' for help."
+ $stderr.puts "Run '#{command} -h' for help."
exit 1
elsif File.exist?(code_or_file)
$0 = code_or_file
@@ -62,7 +63,7 @@ else
eval(code_or_file, binding, __FILE__, __LINE__)
rescue SyntaxError, NameError
$stderr.puts "Please specify a valid ruby command or the path of a script to run."
- $stderr.puts "Run '#{$0} -h' for help."
+ $stderr.puts "Run '#{command} -h' for help."
exit 1
end
end