[Top][All Lists]

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

Re: Behaviour of test -v with assoc array and quote character in key

From: Alex fxmbsw7 Ratchev
Subject: Re: Behaviour of test -v with assoc array and quote character in key
Date: Tue, 23 Feb 2021 12:17:10 +0100

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

reply via email to

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