>From the bash man page:

    compat43
      •      the  shell  does not print a warning message if an attempt
             is made to use a quoted compound assignment as an argument
             to declare (e.g., declare -a foo='(1 2)'). Later  versions
             warn that this usage is deprecated

But  declare -a foo='(1 2)'  does not print a warning in bash 5.2.26, so
that paragraph is at least irrelevant to newer versions of bash that
don't output a warning:

    $ declare -a foo='(1 2)'
    $ declare -p foo BASH_VERSION
    declare -a foo=([0]="1" [1]="2")
    declare -- BASH_VERSION="5.2.26(1)-release"

I also tried the same command in 4.4.23, 5.0.18, and 5.1.16, and they
all didn't output a warning either, so I wonder if that warning actually
ever existed in a release.

I also wonder whether   declare -a foo='(1 2)'   is actually deprecated
since bash 5.1's ${var[@]@K} expansions to copy associative arrays are
often used in:

    declare -A "foo=(${bar[@]@K})"

I guess it is also possible to use @K expansions with eval like so, if
that form is actually to be considered deprecated:

    declare -A foo=(); eval "bar=${foo[@]@K}"
    # or
    eval declare -A "foo=(${bar[@]@K})"

o/
 emanuele6

Reply via email to