-
Notifications
You must be signed in to change notification settings - Fork 613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow spaces between arguments in Rake tasks #94
base: master
Are you sure you want to change the base?
Allow spaces between arguments in Rake tasks #94
Conversation
Please add testcase. |
@hsbt there's already a test for this |
hi everyone, |
Why we faced this defects as #85 with I hope to add another test-case. |
@@ -84,6 +84,11 @@ def init(app_name='rake') | |||
standard_exception_handling do | |||
@name = app_name | |||
args = handle_options | |||
if args.size > 1 && args.last =~ /.*\]/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .*
is not needed in the regular expression.
@@ -84,6 +84,11 @@ def init(app_name='rake') | |||
standard_exception_handling do | |||
@name = app_name | |||
args = handle_options | |||
if args.size > 1 && args.last =~ /.*\]/ | |||
clean_args = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be
if args.size > 1 && args.last =~ /.*\]/
args = [args.join]
end
right?
Also if the only thing that's stopping this from going out is more tests, I'd be happy to write them.
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. |
This pull request allows input like this
rake my_task[arg1, arg2]
to be parsed correctlyinstead of showing the error
Don't know how to build task 'mytask[arg1, '
as describedin https://github.com//issues/85