On 05/06/2011 09:02 AM, Steven W. Orr wrote: > 4.0.35(1)-release (x86_64-redhat-linux-gnu) > > I have a bunch of arrays, and some of the arrays' values are null or > might contain spaces.
printf %q is your friend.
$ a[0]=aaa a[1]= a[2]='bbb ccc'
$ printf '%q ' "${a[@]}"
aaa '' bbb\ \ ccc
> I'd love to see an elegant solution. :-)
OK, so printf %q prefers '' and \ over "", but the end result is an
unambiguous array listing that can be fed back into shell code.
--
Eric Blake [email protected] +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
