bug-bash
[Top][All Lists]
Advanced

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

Re: New array_expand_once option


From: alex xmb ratchev
Subject: Re: New array_expand_once option
Date: Wed, 14 Jun 2023 01:12:50 +0200

On Tue, Jun 13, 2023, 22:21 Chet Ramey <chet.ramey@case.edu> wrote:

> The latest push to the devel branch extends the assoc_expand_once
> semantics to indexed array variables. This means that a construct
> like
>
> export subscript='$(uname >&2 ; echo 0)'
> shopt -s assoc_expand_once
> printf -v a["$subscript"] %s hi
> declare -p a
>
> will no longer run `uname' and assign "hi" to subscript 0. This affects
> shell builtins that take array references as arguments, which undergo one
> round of word expansion before the builtin performs the assignment.
>
> The affected builtins are primarily
>
> printf
> read
> wait
>
> since those assign values to variable names passed as arguments.
>
> The option also affects
>
> declare
> let
> local
> typeset
> test
> [
> unset
>
> For example, the following does not run `uname':
>
> export subscript='$(uname >&2 ; echo 0)'
> shopt -s assoc_expand_once
> let a["$subscript"]+=1
>
> To better describe its functionality, I renamed assoc_expand_once to
> array_expand_once. The old name is still accepted.
>

any word s about [[ -v
.. ?

greets

When the next version of bash is released, the old bash-5.2 behavior (that
> runs `uname' in the above examples) will be available if the shell
> compatibility level is set to 52 or lower.
>
> 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]