On Fri, May 06, 2011 at 11:50:34AM -0400, Chet Ramey wrote: > Eric suggested %q, and that works to a > certain degree, but you can also use > > printf '"%s" ' "${vals[@]}" ; echo > > and get the double-quoting you want.
Fails horribly if the array elements contain double quotes of their own. Realistically, I do NOT advise even attempting this. Do not try to write general functions that operate on arrays, passed by name. Bash truly does not have the tool set to cope with this. I can't stress this strongly enough.