bug-bash
[Top][All Lists]
Advanced

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

Re: Changing the way bash expands associative array subscripts


From: konsolebox
Subject: Re: Changing the way bash expands associative array subscripts
Date: Fri, 2 Apr 2021 03:02:30 +0800

On Fri, Apr 2, 2021 at 2:56 AM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 4/1/21 2:55 PM, konsolebox wrote:
>
> > So to keep compatibility, would this be the right way?
> >
> > if [[ BASH_VERSINFO -ge 6 || BASH_VERSINFO -eq 5 && BASH_VERSINFO -ge 2 ]]; 
> > then
> >      unset() {
> >          set -- "${@//\[/\\[}"
> >          set -- "${@//\]/\\]}"
> >          eval builtin unset "$@"
> >      }
> > fi
>
> To do what, exactly?

To keep this working in both behaviors.

declare -A a
key='$(echo foo)'
a[$key]=1
unset 'a["$key"]'
declare -p a # declare -A a=()

-- 
konsolebox



reply via email to

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