bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature Request: scanf-like parsing


From: Chet Ramey
Subject: Re: Feature Request: scanf-like parsing
Date: Mon, 25 Jan 2021 14:43:27 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1

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    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]