Closed jcoyne closed 2 years ago
Will this cause trouble if one of the option values have spaces? I'm eyeing these arguments that take paths:
-r, [--ruby=PATH] # Path to the Ruby binary of your choice
-m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL)
[--rc=RC] # Path to file containing extra configuration options for rails command
I don't think so. This is how ARGV, would handle them
Is it?
18:40 % cat a.rb
puts ARGV.inspect
18:40 % ruby a.rb "multi word arg in quotes"
["multi word arg in quotes"]
18:40 % ruby a.rb multi arg
["multi", "arg"]
Oh, right, I neglected to think about that case.
Shellwords.shellwords is what we need.
The Rails::Generator::AppGenerator expects the arguments similar to how they would come from ARGV. This means we only need to split on spaces, there is no need to group options and values.
See https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/commands/application/application_command.rb#L26-L28
This was preventing blacklight from testing using "-a propshaft"