what, sorry, mailing stuff isnt much clear to me, ... its not possible to have a var=\'\] ; assoc[$var] ?
On Mon, Feb 22, 2021 at 5:48 PM Chet Ramey <chet.ra...@case.edu> wrote: > On 2/15/21 1:28 PM, Daniel Gröber wrote: > > > On Mon, Feb 15, 2021 at 09:11:48AM -0500, Chet Ramey wrote: > >> `test' is always going to be problematic here because, as a shell > builtin, > >> its arguments undergo a round of word expansions before it's invoked. > It's > >> difficult to reliably detect the closing bracket in an array subscript > as a > >> result, even if the array subscript expansion didn't perform any > expansions > >> on its own. (Consider what would happen if $1 were `]'). > > > > You're absolutely right, I didn't consider the ']' case at all! That > would > > obviously break. So indeed this just user-error then and not really a > bug. > > Well, it's less than ideal. This is why I introduced the assoc_expand_once > option, but as many folks on here will tell you, it's not a perfect > solution. This is one of the cases where it's not. > > I think I have a better way to do it, one that doesn't require using an > extra level of quoting or assoc_expand_once, but I'm not ready to commit > anything yet, and builtins like test/[ and let will always cause problems. > > Chet > > -- > ``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/ > >