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 10:17:54 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1

On 1/22/21 11:54 AM, Oğuz wrote:

Since everyone's making feature requests here, it'd be a shame if I didn't
participate. I think it'd be better if `${assoc[@]@K}' expanded to a word
list instead of a single word.

It does, when it's subject to word splitting. In contexts where no word
splitting takes place, it expands to a single word, since it's supposed to
parallel the `A' transformation. I agree that it might be more useful if it
expanded to multiple words in contexts like

copy=( "${assoc[@]@K}" )

And, having ampersand as a reference for the
matched substring in the replacement part of `${param/pat/rep}` would also
be good.

There has been code to do this for a long time. It's currently tagged for
bash-5.2. If you want to play around with it, look in subst.c for shouldexp_replacement and its caller, and uncomment them. You'll have to
wait for the next devel branch push for a version that works with multibyte
characters -- that should tell you how long it's been there.

--
``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]