[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: |
Sat, 17 Jun 2023 17:08:02 +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.
>
its an opt that have manually to be enabled ?
or is by default on
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/
>
>
- Re: New array_expand_once option, (continued)
- Re: New array_expand_once option, alex xmb ratchev, 2023/06/13
- Re: New array_expand_once option, Chet Ramey, 2023/06/14
- Re: New array_expand_once option, alex xmb ratchev, 2023/06/14
- Re: New array_expand_once option, Chet Ramey, 2023/06/15
- Re: New array_expand_once option, alex xmb ratchev, 2023/06/15
- Re: New array_expand_once option, alex xmb ratchev, 2023/06/17
- Re: New array_expand_once option, Dennis Williamson, 2023/06/17
- Re: New array_expand_once option, alex xmb ratchev, 2023/06/17
- Re: New array_expand_once option, Chet Ramey, 2023/06/19
- Re: New array_expand_once option, Chet Ramey, 2023/06/19
Re: New array_expand_once option,
alex xmb ratchev <=