On 8/19/21 6:37 AM, Léa Gris wrote:

#!/usr/bin/env bash

declare -A assoc=(
  [P]=piano
  [TB]='foldable table'
  ['CH AIR']=chair
)

options=("${assoc[@]@K}")

The best way to clone an associative array is:

declare -A options
eval options=\( "${assoc[@]@K}" \)

The quoting @K performs is eval-safe.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to