2

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?

1 Answers1

2

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
Thomas
  • 1,613
  • 8
  • 8
  • I found more convincing details in [this comment](http://unix.stackexchange.com/questions/24954/when-is-xargs-needed#comment33593_24956) – Judas Iscariot Jun 20 '16 at 00:19