diff options
author | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-05-19 15:13:05 +0900 |
---|---|---|
committer | yuuji.yaginuma <yuuji.yaginuma@gmail.com> | 2017-05-24 16:11:52 +0900 |
commit | 7a154ab380501050e6ce20463de8f702353bceb0 (patch) | |
tree | 7ae1d2ae6e992f482f14d0027bf394076e4b97cf /railties/lib/rails/commands | |
parent | e5a9d289b16592f395fb528c9688604c02bd2e33 (diff) | |
download | rails-7a154ab380501050e6ce20463de8f702353bceb0.tar.gz rails-7a154ab380501050e6ce20463de8f702353bceb0.tar.bz2 rails-7a154ab380501050e6ce20463de8f702353bceb0.zip |
Correctly set user_supplied_options when there is no whitespace in option specification
Current `user_supplied_options` method can not set the value correctly
if there is no space between option and value (e.g., `-p9000`).
This makes it possible to set the value correctly in the case like the above.
Fixes #29138
Diffstat (limited to 'railties/lib/rails/commands')
-rw-r--r-- | railties/lib/rails/commands/server/server_command.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/server/server_command.rb b/railties/lib/rails/commands/server/server_command.rb index cf3903f3ae..ebb4ae795a 100644 --- a/railties/lib/rails/commands/server/server_command.rb +++ b/railties/lib/rails/commands/server/server_command.rb @@ -155,9 +155,16 @@ module Rails def user_supplied_options @user_supplied_options ||= begin # Convert incoming options array to a hash of flags - # ["-p", "3001", "-c", "foo"] # => {"-p" => true, "-c" => true} + # ["-p3001", "-C", "--binding", "127.0.0.1"] # => {"-p"=>true, "-C"=>true, "--binding"=>true} user_flag = {} - @original_options.each_with_index { |command, i| user_flag[command] = true if i.even? } + @original_options.each do |command| + if command.to_s.start_with?("--") + option = command.split("=")[0] + user_flag[option] = true + elsif command =~ /\A(-.)/ + user_flag[Regexp.last_match[0]] = true + end + end # Collect all options that the user has explicitly defined so we can # differentiate them from defaults |