> For straight debugging output, it's probably ok. You might have to
> play with it a little if you want to make it into something you can
> eval from a command substitution to copy an array.
Just another thought,
declare -p aa
is nice for debugging arrays.
help declare
...
-pdisplay t
On 5/6/11 12:00 PM, Greg Wooledge wrote:
> 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 arr
On 5/6/2011 12:05 PM, Chet Ramey wrote:
On 5/6/11 12:00 PM, Greg Wooledge wrote:
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.
Fa
On Fri, May 6, 2011 at 12:00 PM, Greg Wooledge wrote:
> 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
On 5/6/11 12:00 PM, Greg Wooledge wrote:
> 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 arr
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.
Re
On 5/6/11 11: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.
>
> I wanted to write a routine to print out an array. It just takes the name
> of the array as an argument. Bec
On Fri, May 06, 2011 at 11:02:32AM -0400, Steven W. Orr wrote:
> I wanted to write a routine to print out an array. It just takes the name
> of the array as an argument.
Flee in terror. Do not look back.
Oh, wait, you want a useful answer? Switch to ksh93 and use nameref.
You CANNOT do this sa
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'