help-bash
[Top][All Lists]
Advanced

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

Re: question about, why does my code work in normal bash but not bash de


From: alex ratchev
Subject: Re: question about, why does my code work in normal bash but not bash devel
Date: Mon, 25 Apr 2022 17:47:38 +0200

On Mon, Apr 25, 2022, 16:02 Chet Ramey <chet.ramey@case.edu> wrote:

> On 4/24/22 5:08 PM, alex ratchev wrote:
> > the mkmenu in the script
> > and the printf menustr .. it prints a wanted menu by bash 5.1.16 , but on
> > 5.2b from ~ a week ago it prints empty
>
> You're not going to get the variable expansion you want in the subscript:
>
>   mkmenu() {
> declare var
> menustr=
>    for var in $( compgen -A function ) ; do
>   [[ -v help[\$var] ]] ||
> continue
> menustr+="$var <- ${help[$var]}"$'\n'
>    done
>   }
>
> because you quoted it too much. This is what this CHANGES entry means:
>
> k. Bash attempts to expand indexed array subscripts only once when
> executing
>     shell constructs and word expansions.
>
> though it should say `indexed and associative'. In bash-5.2, bash tries to
> behave as if `assoc_expand_once' is set when expanding associative array
> subscripts for shell compound commands and parameter expansions. You can
> set BASH_COMPAT=51 to get the behavior you want.
>

that means..dont \ the $var to make it work ?
i barley understand the english else

>
> There was a pretty spirited discussion about this last year:
>
> https://lists.gnu.org/archive/html/bug-bash/2021-03/msg00056.html
>
> and the bash-5.2 behavior -- which is much safer -- can be reverted with
> the compatibility mode.
>
> --
> ``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]