On 1/25/21 12:53 PM, Greg Wooledge wrote:
On Mon, Jan 25, 2021 at 12:13:25PM -0500, Chet Ramey wrote:
This is good advice. If the double-quoting the @K transformation performs
is not what you need, use the @Q transformation to get something closer.

Those don't do the same thing, though.

Yes, you'll have to to use something like "${!aa[@]}" to get the array keys
and either serialize assignment or construct a new compound assignment.

But my point is the double-quoting (or $'...' quoting) the @K
transformation performs should be good enough for most common uses, and if
you need something else you'll have to do some work.

I must say that the way @K works is surprising.  I would have expected
it to expand to a list of multiple strings (the way "$@" does, and without
the internal quoting).  I guess it's designed to support the new
name=( key1 value1 key2 value2 ...)  syntax, which I haven't used yet,
so I don't know where all the sharp edges are.

The analog is the @A transformation, which also expands to a single string.

It should be quoted enough to survive `eval', unless you're dogmatic about
not using that.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to