2

I have a Bash file called test.sh:

#!/bin/bash
arr=([email protected] [email protected])
ruby testScript.rb $arr

And here's testScript.rb:

ARGV.each{|a| p a}

When I run ./test.sh in the terminal, I get this output:

"[email protected]"

I want my Ruby script to loop through all elements in the Bash array variable $arr. How do I fix my code to do this?

1 Answer 1

4

In the bash script, pass the array like this:

ruby testScript.rb "${arr[@]}"
Sign up to request clarification or add additional context in comments.

1 Comment

Quotes! Quotes are your friend. Use them: ruby testScript.rb "${arr[@]}".

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.