rake
rake copied to clipboard
Allow spaces between arguments in Rake tasks
This pull request allows input like this rake my_task[arg1, arg2] to be parsed correctly
instead of showing the error Don't know how to build task 'mytask[arg1, ' as described
in https://github.com/ruby/rake/issues/85
Please add testcase.
@hsbt there's already a test for this test_can_handle_spaces_between_args in test/test_rake_task_argument_parsing.rb
hi everyone, what is the state of this pull request? I see the test in 10.4.2 version but I cannot find the code there.
Why we faced this defects as https://github.com/ruby/rake/issues/85 with test_can_handle_spaces_between_args ?
I hope to add another test-case.
I think that this is just shell matter and you should use quoted string literal. In the Bash example, please check Bash Reference Manual's several points, Quoting and Word Splitting.
The quoted string literal and word splitting of shell is so complex because of histrical background and Rake is sometimes called by complex shell scripts, such as inside CI, Dockerfile and build scripts. I think this Pull Request is precarious.
For another thing, task name can take any string:
task :'task]' do
puts 'This is task]'
end
The task name what is ended of "]" is within the realm of possibility, for example, some kind of model number because Ruby is general-purpos programming language.
@aycabta's concerns make sense to me. I think @drbrain's comment here is the right approach. Shell strings, quoting, splitting, etc are gnarly, and I suspect it's best to bite the bullet and be explicit by quoting embedded spaces.