Recent Posts

On the Future of the Apple Watch
Venture Capital and Equality
Conserving Water
2014 Summary

Popular in 2014

7th Israeli Origami Convention
Interview with 240 Creator Udi Eylat
Learning to Code

Bash: Passing Arguments with Quotes

Today I needed to write a bash script that eventually calls another program, passing all the arguments to it. It seemed like a simple enough task: just use $@. However, the problem was that the program accepts arguments surrounded with quotes, and the $@ stripped the quotes away. I was really surprised that google didn’t immediately find an answer.

Finally I reached this forum: script-problem-preserving-quotes- arguments.html

And to save you the trouble, here’s a script that preserves the quotes:

# blah blah blah  
./foo "$@"  

For more on posts, see here.