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 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

I found more convincing details in this comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.