Rake removes trailing whitespaces from parameters when task is being executed from command line.
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.5k
- Forks
- 650
- Avg merge
- 6m
- Merged PRs (30d)
- 3
Description
Having a simple rake task:
task :ws, [:str] => :environment do |t, args|
puts args.str.inspect
end
I get following results when run this task in command line:
$ rake ws[' ']
nil
$ rake ws[' ']
nil
$ rake ws[' 1']
" 1"
$ rake ws[' 1 ']
" 1"
$ rake 'ws[ ]'
nil
$ rake 'ws[ ]'
nil
$ rake 'ws[ 1]'
" 1"
$ rake 'ws[ 1 ]'
" 1"
While when the task is being invoked in rails console everything works as expected:
2.3.3 :258 > Rake::Task['ws'].invoke(' ')
" "
2.3.3 :259 > Rake::Task['ws'].reenable
2.3.3 :260 > Rake::Task['ws'].invoke(' ')
" "
2.3.3 :261 > Rake::Task['ws'].reenable
2.3.3 :262 > Rake::Task['ws'].invoke(' 1')
" 1"
2.3.3 :263 > Rake::Task['ws'].reenable
2.3.3 :264 > Rake::Task['ws'].invoke(' 1 ')
" 1 "
Again, it is definitely not the OS who is responsible for that trimming, since it shouldn't trim anything between quote marks. And besides it can be easily tested this way:
task :ws, [:str] => :environment do |t, args|
puts args.str.inspect
puts ARGV[1].inspect
end
then in command line:
$ rake 'ws[ 1 ]' ' 2 '
" 1"
" 2 "
Rake version 12.0.0
some investigation on the issue https://stackoverflow.com/questions/45622716/rake-removes-trailing-whitespaces-from-parameters-how-to-prevent#answer-45623592
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the command-line behavior with the provided rake ws[...] examples and compare it with Rake::Task invocation in the console. Trace the command-line task-argument parsing; done means leading and trailing whitespace in quoted parameters is preserved, matching direct invocation and ARGV.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100