Reputation: 83
I have the following in a_script.rb:
if ARGV.empty?
puts "string_without_spaces 'string with spaces'"
else
p ARGV
end
When I run:
ruby a_script.rb `ruby a_script.rb`
I get the following output:
["string_without_spaces", "'string", "with", "spaces'"]
But instead, I would like to have the following output:
["string_without_spaces", "string with spaces"]
How do I change the script to get the wanted output?
Upvotes: 2
Views: 445
Reputation: 1633
The problem is in your bash command. Backtick is escaping the "
and '
You can use xargs
ruby a_script.rb | xargs ruby a_script.rb
Upvotes: 2