From a06a643e0572b8c983738c068ae637d020188c97 Mon Sep 17 00:00:00 2001 From: Robert Thau Date: Tue, 21 Mar 2017 23:07:07 -0400 Subject: Correctly reset ARGV for "rails runner `CODE' arg arg arg..." The code itself should not be in the ARGV vector. Fixes #28515 --- railties/lib/rails/commands/runner/runner_command.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails/commands/runner/runner_command.rb b/railties/lib/rails/commands/runner/runner_command.rb index 056ad980b9..6864a9726b 100644 --- a/railties/lib/rails/commands/runner/runner_command.rb +++ b/railties/lib/rails/commands/runner/runner_command.rb @@ -16,7 +16,7 @@ module Rails "#{super} [<'Some.ruby(code)'> | ]" end - def perform(code_or_file = nil, *file_argv) + def perform(code_or_file = nil, *command_argv) unless code_or_file help exit 1 @@ -27,9 +27,10 @@ module Rails require_application_and_environment! Rails.application.load_runner + ARGV.replace(command_argv) + if File.exist?(code_or_file) $0 = code_or_file - ARGV.replace(file_argv) Kernel.load code_or_file else begin -- cgit v1.2.3